Changeset 2593 for neercs


Ignore:
Timestamp:
Jul 27, 2008, 11:08:57 AM (12 years ago)
Author:
Pascal Terjan
Message:
  • Disconnect when failing to write to the client
File:
1 edited

Legend:

Unmodified
Added
Removed
  • neercs/trunk/src/server.c

    r2590 r2593  
    4646        ret = write(screen_list->c_socket, msg, strlen(msg));
    4747    if(ret < 0)
     48    {
    4849        fprintf(stderr, "Failed to send message to client: %s\n", strerror(errno));
     50        detach(screen_list);
     51    }
    4952    return ret;
    5053}
     
    7780    void *buf;
    7881    char *buf2;
    79     debug("Resquesting refresh");
    8082    buf = cucul_export_memory (screen_list->cv, "caca", &bytes);
    8183    buf2 = malloc(bytes+8);
     
    8587        connect_client(screen_list);
    8688    if(screen_list->c_socket)
    87         write(screen_list->c_socket, buf2, bytes+8);
     89        if(write(screen_list->c_socket, buf2, bytes+8) <= 0)
     90            detach(screen_list);
    8891    free(buf);
    8992    free(buf2);
     
    9497{
    9598    screen_list->attached = 0;
    96     return send_to_client("DETACH", screen_list);
     99    if(screen_list->c_socket)
     100    {
     101        send_to_client("DETACH", screen_list);
     102        close(screen_list->c_socket);
     103        screen_list->c_socket = 0;
     104    }
     105    return 0;
    97106}
    98107
Note: See TracChangeset for help on using the changeset viewer.