[67] in 6.033-lab

home help back first fref pref prev next nref lref last post

Small bug in multifinger.c

daemon@ATHENA.MIT.EDU (David Mazieres)
Fri Feb 27 23:21:22 1998

Date: Sat, 21 Feb 1998 15:14:56 -0500 (EST)
From: David Mazieres <dm@reeducation-labor.lcs.mit.edu>
To: 6.033-lab@MIT.EDU
Resent-To: 6.033-lab-mtg@menelaus.MIT.EDU
Resent-From: "Kevin 'Bob' Fu" <fubob@mit.edu>

There is a bug in the multifinger.c file of the socket handout.
Successful system calls to not touch the value of errno.  Thus, one
can't assume anything about the value of errno after a write that
returns EOF (which counts as a successful system call).

This has been fixed in the on-line version of multifinger.c at
/mit/6.033/lab/src/usingtcp/.

David

*** multifinger.c~      Wed Feb 18 23:52:19 1998
--- multifinger.c       Sat Feb 21 14:55:55 1998
***************
*** 88,97 ****
  
    n = write (fc->fd, fc->user + fc->user_pos, fc->user_len - fc->user_pos);
    if (n <= 0) {
-     if (errno == EAGAIN)
-       return;
      if (n == 0)
        fprintf (stderr, "%s: EOF\n", fc->host);
      else
        perror (fc->host);
      fcon_free (fc);
--- 88,97 ----
  
    n = write (fc->fd, fc->user + fc->user_pos, fc->user_len - fc->user_pos);
    if (n <= 0) {
      if (n == 0)
        fprintf (stderr, "%s: EOF\n", fc->host);
+     else if (errno == EAGAIN)
+       return;
      else
        perror (fc->host);
      fcon_free (fc);

home help back first fref pref prev next nref lref last post