Re: Preliminary fix for blocked socket closing.

From: Daniel Koepke (dkoepke@california.com)
Date: 01/15/99


I prefer,

  if ((d->has_prompt = process_output(d)) < 0)
    close_socket(d);

>  int process_output(struct descriptor_data *t)
>  {
>    char i[MAX_SOCK_BUF];
>    int written, offset;

     int result;

.
.
.

>    if (t->has_prompt)           /* && !t->connected) */
>      offset = 0;
     else
       offset = 2;

     result = write_to_descriptor(t->descriptor, i + offset, &written);

     if (result == 0)
       write_to_output(i + written + offset, t);

     return (result);

.
.
.

 *  1  All is well and good.
 *  0  The socket write would block, written is modified with the
 *     number of bytes written previously.
 * -1  An error was encountered, disconnect the socket.
 */

 int write_to_descriptor(socket_t desc, const char *txt, int * written)
 {
   size_t total;
   ssize_t bytes_written;

   total = strlen(txt);

   .
   .
   .

>      } else if (bytes_written == 0) {
>        log("WARNING: write_to_descriptor: socket write would block.");

         return (0);

>      } else {
>        txt += bytes_written;
>        total -= bytes_written;
>        *written += bytes_written;
>      }
>    }

     return (1);

> Thoughts?

And yours?

-dak


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/15/00 PST