comparison src/protocols/irc/dcc_send.c @ 13200:33bef17125c2

[gaim-migrate @ 15563] This is the soon-to-be-infamous nonblocking network activity patch that I've been working on. Feel free to yell at me if this makes you unhappy. committer: Tailor Script <tailor@pidgin.im>
author Daniel Atallah <daniel.atallah@gmail.com>
date Thu, 09 Feb 2006 04:17:56 +0000
parents 8e3b85fe4a55
children 5ddde4ad1ca2
comparison
equal deleted inserted replaced
13199:d8f238864c88 13200:33bef17125c2
172 GaimXfer *xfer = data; 172 GaimXfer *xfer = data;
173 struct irc_xfer_send_data *xd = xfer->data; 173 struct irc_xfer_send_data *xd = xfer->data;
174 char *buffer[16]; 174 char *buffer[16];
175 int len; 175 int len;
176 176
177 if ((len = read(source, buffer, sizeof(buffer))) <= 0) { 177 len = read(source, buffer, sizeof(buffer));
178
179 if (len < 0 && errno == EAGAIN)
180 return;
181 else if (len < 0) {
182 /* XXX: Shouldn't this be canceling the transfer? */
178 gaim_input_remove(xd->inpa); 183 gaim_input_remove(xd->inpa);
179 xd->inpa = 0; 184 xd->inpa = 0;
180 return; 185 return;
181 } 186 }
182 187
207 xd->inpa = 0; 212 xd->inpa = 0;
208 gaim_xfer_set_completed(xfer, TRUE); 213 gaim_xfer_set_completed(xfer, TRUE);
209 gaim_xfer_end(xfer); 214 gaim_xfer_end(xfer);
210 return; 215 return;
211 } 216 }
212
213
214 } 217 }
215 } 218 }
216 219
217 static gssize irc_dccsend_send_write(const guchar *buffer, size_t size, GaimXfer *xfer) 220 static gssize irc_dccsend_send_write(const guchar *buffer, size_t size, GaimXfer *xfer)
218 { 221 {
219 gssize s; 222 gssize s;
223 int ret;
220 224
221 s = MIN(gaim_xfer_get_bytes_remaining(xfer), size); 225 s = MIN(gaim_xfer_get_bytes_remaining(xfer), size);
222 if (!s) 226 if (!s)
223 return 0; 227 return 0;
224 228
225 return write(xfer->fd, buffer, s); 229 ret = write(xfer->fd, buffer, s);
230
231 if (ret < 0 && errno == EAGAIN)
232 ret = 0;
233
234 return ret;
226 } 235 }
227 236
228 static void irc_dccsend_send_connected(gpointer data, int source, GaimInputCondition cond) { 237 static void irc_dccsend_send_connected(gpointer data, int source, GaimInputCondition cond) {
229 GaimXfer *xfer = (GaimXfer *) data; 238 GaimXfer *xfer = (GaimXfer *) data;
230 struct irc_xfer_send_data *xd = xfer->data; 239 struct irc_xfer_send_data *xd = xfer->data;