@@ -175,24 +175,32 @@ void *remoteShell_connection_run(void *data) {
175175 char buff [COMMAND_BUFF_SIZE ];
176176
177177 len = recv (fd , buff , COMMAND_BUFF_SIZE - 1 , 0 );
178- if (len < COMMAND_BUFF_SIZE ) {
179- celix_status_t commandStatus = CELIX_SUCCESS ;
180- buff [len ] = '\0' ;
181-
182- commandStatus = remoteShell_connection_execute (connection , buff );
183-
184- if (commandStatus == CELIX_SUCCESS ) {
185- remoteShell_connection_print (connection , RS_PROMPT );
186- } else if (commandStatus == CELIX_FILE_IO_EXCEPTION ) {
187- //exit command
188- break ;
189- } else { //error
190- remoteShell_connection_print (connection , RS_ERROR );
191- remoteShell_connection_print (connection , RS_PROMPT );
178+ if (len > 0 ) {
179+ if (len < COMMAND_BUFF_SIZE ) {
180+ celix_status_t commandStatus = CELIX_SUCCESS ;
181+ buff [len ] = '\0' ;
182+
183+ commandStatus = remoteShell_connection_execute (connection , buff );
184+
185+ if (commandStatus == CELIX_SUCCESS ) {
186+ remoteShell_connection_print (connection , RS_PROMPT );
187+ } else if (commandStatus == CELIX_FILE_IO_EXCEPTION ) {
188+ //exit command
189+ break ;
190+ } else { //error
191+ remoteShell_connection_print (connection , RS_ERROR );
192+ remoteShell_connection_print (connection , RS_PROMPT );
193+ }
194+
195+ } else {
196+ celix_logHelper_log (* connection -> parent -> loghelper , CELIX_LOG_LEVEL_ERROR , "REMOTE_SHELL: Error while retrieving data" );
192197 }
193-
198+ } else if (len == 0 ) {
199+ celix_logHelper_log (* connection -> parent -> loghelper , CELIX_LOG_LEVEL_INFO , "REMOTE_SHELL: Connection closed by peer" );
200+ break ;
194201 } else {
195- celix_logHelper_log (* connection -> parent -> loghelper , CELIX_LOG_LEVEL_ERROR , "REMOTE_SHELL: Error while retrieving data" );
202+ celix_logHelper_log (* connection -> parent -> loghelper , CELIX_LOG_LEVEL_ERROR , "REMOTE_SHELL: recv() failed: %s" , strerror (errno ));
203+ break ;
196204 }
197205 }
198206 }
0 commit comments