Iterative use easy to use low-level errors

xiaoxiao2021-03-06  40

A mistake in my 2 months

Developed a server, internally testing, the first external test has no problem. When it is the most important, the problem is constantly - the program is exited for no reason (thinking is a multithreading access to the shared resource problem). Time tight is only necessary for remedies. There have been no mistakes in the past (because the environment of external testing, I don't have the right to move it - in another city), then take over the client's development. After the basic completion, there is time to come back to unclear the code and perform unit function testing. I used the ACE framework, using its ACE_HASH_MAP_MANAGER <>, using access control is ACE_RW_MUTEX, the first suspicion of the beginning is inevitably this access is controlled, first add a lock to this MAP, 3 Threads are accessed simultaneously - still have problems, and single-threaded access is not. Only give up this idea, look at the forum in the forum in the case of hundreds of ideas: Vector :: item (vector :: item t = vec.begin (); ore! = Vec.end (); iter) {if (* iter == 1) VEC.RASE (iter);} I still went to say how wrong, I came back after a circle, and I watched my code - dizzy, I actually made this kind of Low-level error - In the traversal loop, try to find a (some) matching elements and delete it. Move the delete part to the outside, then perform the above test (I use this MAP) in the actual use of this MAP, OK.

转载请注明原文地址:https://www.9cbs.com/read-61200.html

New Post(0)