Skip to contentSkip to conversation

network/echoes: fix endless loop on error

PATCH New Petr Vorel 2 participants 6 messages Nov 29, 2016 – Dec 15, 2016 1 message not in the archive

lore
Share & tools
lore

Petr Vorel

author
#0 lore raw

PATCH 1/1 network/echoes: fix endless loop on error

---
 testcases/network/tcp_cmds/echo/echoes.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
testcases/network/tcp_cmds/echo/echoes.c +4 -1
index 8138d28..d753d98 100644
@@ -97,6 +97,7 @@ int main(int argc, char *argv[], char *env[])
 
 		if ((pid = wait(&wait_stat)) == -1)
 			tst_resm(TFAIL | TERRNO, "wait failed");
+
 		if (wait_stat == 0) {
 			for (j = 0; j < i; j++) {
 				if (echo_struc[j].pid == pid) {
@@ -105,7 +106,6 @@ int main(int argc, char *argv[], char *env[])
 				}
 			}
 		} else {
-
 			tst_resm(TFAIL, "wait(2) status was non-zero");
 
 			if (WIFEXITED(wait_stat)) {
@@ -120,6 +120,9 @@ int main(int argc, char *argv[], char *env[])
 				if (kill(echo_struc[k].pid, 0) == 0) {
 					kill(echo_struc[k].pid, 9);
 				}
+				if (echo_struc[k].pid == pid) {
+					finish--;
+				}
 			}
 
 		}
Signature · 1 line
2.10.2
#1 lore raw

PATCH 1/1 network/echoes: fix endless loop on error

Hi,

Quoted 26 lines · Petr Vorel
---
  testcases/network/tcp_cmds/echo/echoes.c | 5 ++++-
  1 file changed, 4 insertions(+), 1 deletion(-)
testcases/network/tcp_cmds/echo/echoes.c +1 -1
index 8138d28..d753d98 100644
@@ -97,6 +97,7 @@ int main(int argc, char *argv[], char *env[])
 
  		if ((pid = wait(&wait_stat)) == -1)
  			tst_resm(TFAIL | TERRNO, "wait failed");
+
  		if (wait_stat == 0) {
  			for (j = 0; j < i; j++) {
  				if (echo_struc[j].pid == pid) {
@@ -105,7 +106,6 @@ int main(int argc, char *argv[], char *env[])
  				}
  			}
  		} else {
-
  			tst_resm(TFAIL, "wait(2) status was non-zero");
 
  			if (WIFEXITED(wait_stat)) {

testcases/network/tcp_cmds/echo/echoes.c int main(int argc, char *argv[], char *env[]) · line 125

Quoted 6 lines
testcases/network/tcp_cmds/echo/echoes.c +3 -0
@@ -120,6 +120,9 @@ int main(int argc, char *argv[], char *env[])
  				if (kill(echo_struc[k].pid, 0) == 0) {
  					kill(echo_struc[k].pid, 9);
  				}
+				if (echo_struc[k].pid == pid) {
+					finish--;
+				}

Good catch, looks like we could substitute the while loop here with tst_reap_children() library function and remove "echo_struc" as well?

Thanks,
Alexey

author
#2 lore raw

PATCH 1/1 network/echoes: fix endless loop on error

Hi,

thanks for your review Alexey!

Quoted 2 lines

Good catch, looks like we could substitute the while loop here with tst_reap_children() library function and remove "echo_struc" as well?

OK :-). Needs to be rewritten into new API, then.

Kind regards,
Petr
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.linux.it/pipermail/ltp/attachments/20161206/08cecc29/attachment.sig>

author
#3 lore raw

PATCH 1/1 network/echoes: fix endless loop on error

In reply to Alexey Kodanev

Hi Alexey,

Quoted 2 lines

Good catch, looks like we could substitute the while loop here with tst_reap_children() library function and remove "echo_struc" as well?

Could you please push this quick fix? I plan to rewrite test into new API, but probably will not manage it until the release.

Kind regards,
Petr
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.linux.it/pipermail/ltp/attachments/20161214/fc9d9bdd/attachment.sig>

#4 lore raw

PATCH 1/1 network/echoes: fix endless loop on error

Hi Petr,

Quoted 6 lines · Petr Vorel

Hi Alexey,

Quoted 2 lines

Good catch, looks like we could substitute the while loop here with tst_reap_children() library function and remove "echo_struc" as well?

Could you please push this quick fix? I plan to rewrite test into new API, but probably will not manage it until the release.

OK, but if we want a quick fix here we can just add a single "break" after the loop where
it is killing all the left child processes. No need to proceed anyway. If you agree I'll push
the patch with the break version:

testcases/network/tcp_cmds/echo/echoes.c +1 -1
@@ -121,7 +121,7 @@ int main(int argc, char *argv[], char *env[])
                                         kill(echo_struc[k].pid, 9);
                                 }
                         }
-
+                       break;
                 }
 
         }

Thanks,
Alexey

A message that is not in the archive (sent off-list or not yet received): 20161215115111.srk5fmrehsllbhuw@x230

#6 lore raw

PATCH 1/1 network/echoes: fix endless loop on error

Quoted 8 lines · Petr Vorel

Hi Alexey,

Quoted 5 lines

OK, but if we want a quick fix here we can just add a single "break" after the loop where
it is killing all the left child processes. No need to proceed anyway. If you agree I'll push
the patch with the break version:

Sure, push this version. Thanks!

Applied the patch, thank you.

Best regards,
Alexey