comparison libpurple/protocols/oscar/flap_connection.c @ 17671:648551e3243a

Only check for EAGAIN if send returns -1, not when it returns 0
author Mark Doliner <mark@kingant.net>
date Sun, 03 Jun 2007 19:04:22 +0000
parents f80f7e1047be
children a88796a81413
comparison
equal deleted inserted replaced
17670:3522a4cda52f 17671:648551e3243a
301 oscar_chat_destroy(conn->new_conn_data); 301 oscar_chat_destroy(conn->new_conn_data);
302 conn->connect_data = NULL; 302 conn->connect_data = NULL;
303 } 303 }
304 } 304 }
305 305
306 if (conn->fd != -1) 306 if (conn->fd >= 0)
307 { 307 {
308 if (conn->type == SNAC_FAMILY_LOCATE) 308 if (conn->type == SNAC_FAMILY_LOCATE)
309 flap_connection_send_close(od, conn); 309 flap_connection_send_close(od, conn);
310 310
311 close(conn->fd); 311 close(conn->fd);
790 OSCAR_DISCONNECT_REMOTE_CLOSED, NULL); 790 OSCAR_DISCONNECT_REMOTE_CLOSED, NULL);
791 break; 791 break;
792 } 792 }
793 793
794 /* If there was an error then close the connection */ 794 /* If there was an error then close the connection */
795 if (read == -1) 795 if (read < 0)
796 { 796 {
797 if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) 797 if ((errno == EAGAIN) || (errno == EWOULDBLOCK))
798 /* No worries */ 798 /* No worries */
799 break; 799 break;
800 800
851 flap_connection_schedule_destroy(conn, 851 flap_connection_schedule_destroy(conn,
852 OSCAR_DISCONNECT_REMOTE_CLOSED, NULL); 852 OSCAR_DISCONNECT_REMOTE_CLOSED, NULL);
853 break; 853 break;
854 } 854 }
855 855
856 if (read == -1) 856 if (read < 0)
857 { 857 {
858 if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) 858 if ((errno == EAGAIN) || (errno == EWOULDBLOCK))
859 /* No worries */ 859 /* No worries */
860 break; 860 break;
861 861
900 } 900 }
901 901
902 ret = send(conn->fd, conn->buffer_outgoing->outptr, writelen, 0); 902 ret = send(conn->fd, conn->buffer_outgoing->outptr, writelen, 0);
903 if (ret <= 0) 903 if (ret <= 0)
904 { 904 {
905 if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) 905 if (ret < 0 && ((errno == EAGAIN)) || ((errno == EWOULDBLOCK)))
906 /* No worries */ 906 /* No worries */
907 return; 907 return;
908 908
909 /* Error! */ 909 /* Error! */
910 purple_input_remove(conn->watcher_outgoing); 910 purple_input_remove(conn->watcher_outgoing);
934 934
935 /* Add everything to our outgoing buffer */ 935 /* Add everything to our outgoing buffer */
936 purple_circ_buffer_append(conn->buffer_outgoing, bs->data, count); 936 purple_circ_buffer_append(conn->buffer_outgoing, bs->data, count);
937 937
938 /* If we haven't already started writing stuff, then start the cycle */ 938 /* If we haven't already started writing stuff, then start the cycle */
939 if ((conn->watcher_outgoing == 0) && (conn->fd != -1)) 939 if ((conn->watcher_outgoing == 0) && (conn->fd >= 0))
940 { 940 {
941 conn->watcher_outgoing = purple_input_add(conn->fd, 941 conn->watcher_outgoing = purple_input_add(conn->fd,
942 PURPLE_INPUT_WRITE, send_cb, conn); 942 PURPLE_INPUT_WRITE, send_cb, conn);
943 send_cb(conn, conn->fd, 0); 943 send_cb(conn, conn->fd, 0);
944 } 944 }