Odd problem w/ RETURN?
vining
Posts: 4,368
I'm running this code:
Diagnostics:
The STOP SERVER lines that precede and follow the red high lighted line in the diagnostics print out are from the fnSServer_StopExtras(i) function called just before the red high lighted line in the code snippet.
if(nNext) { nNext++; if(nNext > SSERV_NUM_SERVERS) { nNext = SSERV_FIRST_SSERVER; } else if(nNext < SSERV_FIRST_SSERVER) { nNext = SSERV_FIRST_SSERVER; } for(i = nNext; i <= SSERV_NUM_SERVERS; i ++) { if(nSServerStats[i][SSERV_STAT_STATE] == IP_SERVER_STOPPED && !nSServerStats[i][SSERV_STAT_AUTOSTART] && nSServerStats[i][SSERV_STAT_TYPE] == 1) //stopped and not autostart { fnSServer_StopExtras(i);//stops others if listening? nSServPendingListener = i; [COLOR=#FF0000]fnSServer_DeBug("'STARTING SERVER [ ',itoa(i),' ] to listen on port (',itoa(nSServerStats[i][SSERV_STAT_IP_PORT]),') <',ITOA(__LINE__),'>'");[/COLOR] SEND_COMMAND vSERVER_Arry[i],'START_SERVER'; RETURN; } } }
Diagnostics:
Line 290 (00:00:08):: (***********************************************************) Line 291 (00:00:08):: Sitrep Server Mod 4, Has Client Connected Line 292 (00:00:08):: (***********************************************************) Line 293 (00:00:08):: $0D Line 294 (00:00:08):: SERVER-mod 4,(1) DEBUG: CLIENT ONLINE Line 295 (00:00:08):: SERVER.axi -,(1) DEBUG: RX SERVER-[4]: STATE CHANGE, NEW STATE-[ CONNECTED ], OLD STATE-[ LISTENING ] <873> Line 296 (00:00:08):: SERVER.axi -,(1) DEBUG: STOP SERVER [ 2 ] not listening, do nothing <692> Line 297 (00:00:08):: SERVER.axi -,(1) DEBUG: STOP SERVER [ 3 ] not listening, do nothing <692> Line 298 (00:00:08):: SERVER.axi -,(1) DEBUG: STOP SERVER [ 4 ] not listening, do nothing <692> Line 299 (00:00:08):: SERVER.axi -,(1) DEBUG: STOP SERVER [ 5 ] last started, left to listen <676> Line 300 (00:00:08):: SERVER.axi -,(1) DEBUG: STOP SERVER [ 6 ] not listening, do nothing <692> [COLOR=#FF0000]Line 301 (00:00:08):: SERVER.axi -,(1) DEBUG: STARTING SERVER [ 5 ] to listen on port (8101) <656>[/COLOR] Line 302 (00:00:08):: SERVER.axi -,(1) DEBUG: STOP SERVER [ 2 ] not listening, do nothing <692> Line 303 (00:00:08):: SERVER.axi -,(1) DEBUG: STOP SERVER [ 3 ] not listening, do nothing <692> Line 304 (00:00:08):: SERVER.axi -,(1) DEBUG: STOP SERVER [ 4 ] not listening, do nothing <692> Line 305 (00:00:08):: SERVER.axi -,(1) DEBUG: STOP SERVER [ 5 ] not listening, do nothing <692> Line 306 (00:00:08):: SERVER.axi -,(1) DEBUG: STOP SERVER [ 6 ] last started, left to listen <676> Line 307 (00:00:08):: SERVER.axi -,(1) DEBUG: STARTING SERVER [ 6 ] to listen on port (8101) <656> Line 308 (00:00:08):: SERVER-mod 5,(1) DEBUG: Virtual RX Cmd: (START_SERVER) :DEBUG<1426> Line 309 (00:00:08):: SERVER-mod 5,(1) DEBUG: OPENING SERVER :DEBUG<250> Line 310 (00:00:08):: SERVER-mod 5,(1) DEBUG: SITREP Server Open successful, listening on port (8101) :DEBUG<266> Line 311 (00:00:08):: SERVER-mod 6,(1) DEBUG: Virtual RX Cmd: (START_SERVER) :DEBUG<1426> Line 312 (00:00:08):: SERVER-mod 6,(1) DEBUG: OPENING SERVER :DEBUG<250> Line 313 (00:00:08):: SERVER-mod 6,(1) DEBUG: SITREP Server Open successful, listening on port (8101) :DEBUG<266> Line 314 (00:00:08):: SERVER.axi -,(1) DEBUG: RX SERVER-[5]: STATE CHANGE, NEW STATE-[ PENDING ], OLD STATE-[ STOPPED ] <873> Line 315 (00:00:08):: SERVER.axi -,(1) DEBUG: RX SERVER-[5]: STATE CHANGE, NEW STATE-[ LISTENING ], OLD STATE-[ PENDING ] <873> Line 316 (00:00:08):: SERVER.axi -,(1) DEBUG: STOP SERVER [ 2 ] not listening, do nothing <692> Line 317 (00:00:08):: SERVER.axi -,(1) DEBUG: STOP SERVER [ 3 ] not listening, do nothing <692> Line 318 (00:00:08):: SERVER.axi -,(1) DEBUG: STOP SERVER [ 4 ] not listening, do nothing <692> Line 319 (00:00:08):: SERVER.axi -,(1) DEBUG: STOP SERVER [ 5 ] last started, left to listen <676> Line 320 (00:00:08):: SERVER.axi -,(1) DEBUG: STOP SERVER [ 6 ] not listening, do nothing <692> Line 321 (00:00:08):: SERVER.axi -,(1) DEBUG: RX SERVER-[6]: STATE CHANGE, NEW STATE-[ PENDING ], OLD STATE-[ STOPPED ] <873> Line 322 (00:00:08):: SERVER-mod 4,(1) DEBUG: STRING: *********$0D$0A :DEBUG<1338>On line 301 we can see it the code reached the line high lighted in red in the snippet and it should have then sent the command and hit the RETURN and exited the function but instead it finished the for loop which is this case max's out at 6. This doesn't normally happen either and if it did exit this function there would have been other diagnostic lines printed before this function could be called again. Very odd?
The STOP SERVER lines that precede and follow the red high lighted line in the diagnostics print out are from the fnSServer_StopExtras(i) function called just before the red high lighted line in the code snippet.
DEFINE_FUNCTION fnSServer_StopExtras(INTEGER iIndx) //stop all listening servers but one { STACK_VAR INTEGER i; for(i = SSERV_FIRST_SSERVER; i <= SSERV_NUM_SERVERS; i ++) { if(i == iIndx)//server just started { fnSServer_DeBug("'STOP SERVER [ ',itoa(i),' ] last started, left to listen <',ITOA(__LINE__),'>'"); } else if(nSServerStats[i][SSERV_STAT_STATE] == IP_SERVER_LISTENING) { if(nSServerStats[i][SSERV_STAT_AUTOSTART] == 1) { fnSServer_DeBug("'STOP SERVER [ ',itoa(i),' ] listening and set to "auto connect", leaving alone <',ITOA(__LINE__),'>'"); } else//shut down all listening other than the last to start { fnSServer_DeBug("'STOP SERVER [ ',itoa(i),' ] listening, sending "stop" cmd to mod (',itoa(i),') <',ITOA(__LINE__),'>'"); SEND_COMMAND vSERVER_Arry[i],'STOP_SERVER'; } } else { fnSServer_DeBug("'STOP SERVER [ ',itoa(i),' ] not listening, do nothing <',ITOA(__LINE__),'>'"); } } RETURN; }
0
Comments
Anyway I'm sure using RETURN the way I did is fine and I'm sure I've done this many times, just can't remember?