comparison libpurple/win32/libc_interface.c @ 20922:d9cbd249619b

Fix all our calls to fcntl(listenfd, F_SETFL, O_NONBLOCK); fcntl() with F_SETFL overwrites the old flags with the new ones, so you should call fcntl() with F_GETFL, then OR that value with O_NONBLOCK before setting the flags. We've been doing this wrong for a long time and it hasn't seemed to hurt anything, but I thought it would be good to fix it.
author Mark Doliner <mark@kingant.net>
date Sun, 14 Oct 2007 09:57:32 +0000
parents 44b4e8bd759b
children 35b4f1dc4c8d
comparison
equal deleted inserted replaced
20921:b2b16843851b 20922:d9cbd249619b
136 return ret; 136 return ret;
137 } 137 }
138 138
139 /* fcntl.h */ 139 /* fcntl.h */
140 /* This is not a full implementation of fcntl. Update as needed.. */ 140 /* This is not a full implementation of fcntl. Update as needed.. */
141 int wpurple_fcntl(int socket, int command, int val) { 141 int wpurple_fcntl(int socket, int command, ...) {
142
142 switch( command ) { 143 switch( command ) {
144 case F_GETFL:
145 return 0;
146
143 case F_SETFL: 147 case F_SETFL:
144 { 148 {
149 va_list args;
150 int val;
145 int ret=0; 151 int ret=0;
152
153 va_start(args, command);
154 val = va_arg(args, int);
155 va_end(args);
146 156
147 switch( val ) { 157 switch( val ) {
148 case O_NONBLOCK: 158 case O_NONBLOCK:
149 { 159 {
150 u_long imode=1; 160 u_long imode=1;
151 ret = ioctlsocket(socket, FIONBIO, &imode); 161 ret = ioctlsocket(socket, FIONBIO, &imode);
152 break; 162 break;
153 } 163 }
154 case 0: 164 case 0:
155 { 165 {
156 u_long imode=0; 166 u_long imode=0;
157 ret = ioctlsocket(socket, FIONBIO, &imode); 167 ret = ioctlsocket(socket, FIONBIO, &imode);
158 break; 168 break;
159 } 169 }
160 default: 170 default: