summaryrefslogtreecommitdiff
path: root/bgpd/bgp_packet.c
diff options
context:
space:
mode:
authorpaul <paul>2005-01-05 08:14:13 +0000
committerpaul <paul>2005-01-05 08:14:13 +0000
commita24a7e1b9e145d4c855d0aa4d919a79f598c645b (patch)
tree02236b0424330cce2c902a9a971829a3610bac25 /bgpd/bgp_packet.c
parent6c20046fd7494f9f529dac1b6f79da51b6efa44d (diff)
2005-01-05 Paul Jakma <paul@dishone.st>
* bgp_packet.c: (bgp_write) set socket to nonblock while writing this should be generalised. See bugzilla #102. Fix supplied by wawa@yandex-team.ru (Vladimir Ivanov).
Diffstat (limited to 'bgpd/bgp_packet.c')
-rw-r--r--bgpd/bgp_packet.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c
index 4eb7050c..5640e2b7 100644
--- a/bgpd/bgp_packet.c
+++ b/bgpd/bgp_packet.c
@@ -566,10 +566,17 @@ bgp_write (struct thread *thread)
while (1)
{
int writenum;
+ int val;
s = bgp_write_packet (peer);
if (! s)
return 0;
+
+ /* XXX: FIXME, the socket should be NONBLOCK from the start
+ * status shouldnt need to be toggled on each write
+ */
+ val = fcntl (peer->fd, F_GETFL, 0);
+ fcntl (peer->fd, F_SETFL, val|O_NONBLOCK);
/* Number of bytes to be sent. */
writenum = stream_get_endp (s) - stream_get_getp (s);
@@ -577,6 +584,7 @@ bgp_write (struct thread *thread)
/* Call write() system call. */
num = write (peer->fd, STREAM_PNT (s), writenum);
write_errno = errno;
+ fcntl (peer->fd, F_SETFL, val);
if (num <= 0)
{
/* Partial write. */