I am developing a program that is designed to run on different types of servers. Functions given in the question, republished below, list of "friends" and every "friend" in the list has been retrieved, it performs a handshake (through ping_and_report, not shown) is.
The problem is that for the first time calling this routine, strtok_r seems to return more strings than it is present in the source, and I can not determine why the code:
Zero PingServar list (int dummy) {char * p; Char * my_friends; Four * Next SVR, * savePtr; ; Four * separator = ",; \ t"; Server_list_t * ent = NULL; Fixed long round_nbr = 0; Unsigned int lane; Now time; Four messages [4096]; Four * hex; Round_nb ++; P = get_server_list (); If (p) {len = strlen (p); My_friends = Molok (Lane + 1); Strncpy (my_friends, p, len); } NextSvr = strtok_r (my_friends, separators, and savePtr); While (nextSvr) {// Make sure no one spoils with the next SVR. . Char * workSvr = malloc (strlen (nextSvr) + 1); Streakpie (Work S VR, Next S VR); If (debug) {len = strlen (workSvr) * 2 + 3; Hex = maul (lane); Get_hex_val (workSvr, hex, lane); Write_log (fp_debug, "server:% s (x '% s')", workshear, hex); Free (hex); } Ping_and_report (workSvr, round_nbr); Free (work SVR); NextSvr = strtok_r (NULL, separator, and savePtr); } ... is not too complicated at that point, I think. And I do not see any room to roam the values, but this issue has been revealed in the log file:
2012-07-09 23:26 debug activated ... 2012 -07-09 23:26 get_server_list () Return to velmicro, stora-2 (X'76656C6D6963726F2C2073746F72612D32 ') 2012-07-09 23:26 Server: velmicro (x'76656C6D6963726F') 2012-07-09 23:26 Server : Stora-2 (x'73746F72612D32 ') 2012-07-09 23:26 Server: Again (x'726519') The crazy thing is this (at least many of the code By hanging) This will only fail on the first call. 2-N calls (where n is in hundreds) does not display this problem.
Is any of you looking at what I am missing? (BTW: This completely fails on four separate systems with versions of Linux.)
When you type
strncpy (my_friends, p, len); You are not sure that my_friends ends with one \ < try
strncpy (my_friends, p, lane) [lane -1] = '\ 0'; Use callto to assign Alt My_friends
Comments
Post a Comment