aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2006-05-14 00:30:51 +0200
committerWilmer van der Gaast <wilmer@gaast.net>2006-05-14 00:30:51 +0200
commit0356ae3aa10bb6556d0ea881988831cad5e71f38 (patch)
tree9b4ca051f6bcce4a45876bdef53ad47e909ca305
parent19ac9c5c98a8d5adf22bcf5b8e2d4141c82a3275 (diff)
irc_vawrite() now first attempts to write() immediately (because that's
usually not a problem) and only touches the event queue when the write() doesn't write everything. And got rid of a quit element in the irc_t structure that actually wasn't even used.
-rw-r--r--irc.c12
-rw-r--r--irc.h1
2 files changed, 10 insertions, 3 deletions
diff --git a/irc.c b/irc.c
index 8112a3e8..6ae0e108 100644
--- a/irc.c
+++ b/irc.c
@@ -575,7 +575,8 @@ void irc_vawrite( irc_t *irc, char *format, va_list params )
int size;
char line[IRC_MAX_LINE+1], *cs;
- if( irc->quit )
+ /* Don't try to write anything new anymore when shutting down. */
+ if( irc->status == USTATUS_SHUTDOWN )
return;
line[IRC_MAX_LINE] = 0;
@@ -604,7 +605,14 @@ void irc_vawrite( irc_t *irc, char *format, va_list params )
}
if( irc->w_watch_source_id == 0 )
- irc->w_watch_source_id = b_input_add( irc->fd, GAIM_INPUT_WRITE, bitlbee_io_current_client_write, irc );
+ {
+ /* If the buffer is empty we can probably write, so call the write event handler
+ immediately. If it returns TRUE, it should be called again, so add the event to
+ the queue. If it's FALSE, we emptied the buffer and saved ourselves some work
+ in the event queue. */
+ if( bitlbee_io_current_client_write( irc, irc->fd, GAIM_INPUT_WRITE ) )
+ irc->w_watch_source_id = b_input_add( irc->fd, GAIM_INPUT_WRITE, bitlbee_io_current_client_write, irc );
+ }
return;
}
diff --git a/irc.h b/irc.h
index 394e1d54..fdb016cb 100644
--- a/irc.h
+++ b/irc.h
@@ -60,7 +60,6 @@ typedef struct irc
int pinging;
char *sendbuffer;
char *readbuffer;
- int quit;
int sentbytes;
time_t oldtime;