Changeset 7de07a0
- Timestamp:
- 2018-07-12T08:42:45Z (6 years ago)
- Parents:
- b9d1fdc
- git-author:
- dequis <dx@…> (12-07-18 08:30:59)
- git-committer:
- dequis <dx@…> (12-07-18 08:42:45)
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
bitlbee.c
rb9d1fdc r7de07a0 236 236 irc_t *irc = data; 237 237 int st, size; 238 char *temp; 239 240 if (irc->sendbuffer == NULL) { 241 return FALSE;242 }243 244 size = strlen(irc->sendbuffer); 245 st = write(irc->fd, irc->sendbuffer , size);238 239 size = irc->sendbuffer->len; 240 241 if (size == 0) { 242 return FALSE; 243 } 244 245 st = write(irc->fd, irc->sendbuffer->str, size); 246 246 247 247 if (st == 0 || (st < 0 && !sockerr_again())) { … … 253 253 254 254 if (st == size) { 255 g_free(irc->sendbuffer); 256 irc->sendbuffer = NULL; 255 g_string_truncate(irc->sendbuffer, 0); 257 256 irc->w_watch_source_id = 0; 258 257 259 258 return FALSE; 260 259 } else { 261 temp = g_strdup(irc->sendbuffer + st); 262 g_free(irc->sendbuffer); 263 irc->sendbuffer = temp; 260 g_string_erase(irc->sendbuffer, 0, st); 264 261 265 262 return TRUE; -
irc.c
rb9d1fdc r7de07a0 62 62 irc->iconv = (GIConv) - 1; 63 63 irc->oconv = (GIConv) - 1; 64 65 irc->sendbuffer = g_string_sized_new(IRC_MAX_LINE * 2); 64 66 65 67 if (global.conf->ping_interval > 0 && global.conf->ping_timeout > 0) { … … 305 307 } 306 308 307 g_ free(irc->sendbuffer);309 g_string_free(irc->sendbuffer, TRUE); 308 310 g_free(irc->readbuffer); 309 311 g_free(irc->password); … … 595 597 596 598 if (now) { 597 g_free(irc->sendbuffer); 598 irc->sendbuffer = g_strdup("\r\n"); 599 g_string_assign(irc->sendbuffer, "\r\n"); 599 600 } 600 601 irc_vawrite(temp->data, format, params); … … 611 612 void irc_vawrite(irc_t *irc, char *format, va_list params) 612 613 { 613 int size;614 614 char line[IRC_MAX_LINE + 1]; 615 615 … … 638 638 g_strlcat(line, "\r\n", IRC_MAX_LINE + 1); 639 639 640 if (irc->sendbuffer != NULL) { 641 gsize line_len = strlen(line); 642 gsize buffer_len = strlen(irc->sendbuffer); 643 644 size = buffer_len + line_len; 645 irc->sendbuffer = g_renew(char, irc->sendbuffer, size + 1); 646 strcpy((irc->sendbuffer + buffer_len), line); 647 } else { 648 irc->sendbuffer = g_strdup(line); 649 } 640 g_string_append(irc->sendbuffer, line); 650 641 651 642 if (irc->w_watch_source_id == 0) { … … 669 660 { 670 661 ssize_t n; 671 size_t len ;672 673 if ( irc->sendbuffer == NULL) {662 size_t len = irc->sendbuffer->len; 663 664 if (len == 0) { 674 665 return; 675 666 } 676 667 677 len = strlen(irc->sendbuffer); 678 if ((n = send(irc->fd, irc->sendbuffer, len, 0)) == len) { 679 g_free(irc->sendbuffer); 680 irc->sendbuffer = NULL; 668 if ((n = send(irc->fd, irc->sendbuffer->str, len, 0)) == len) { 669 g_string_truncate(irc->sendbuffer, 0); 681 670 682 671 b_event_remove(irc->w_watch_source_id); 683 672 irc->w_watch_source_id = 0; 684 673 } else if (n > 0) { 685 char *s = g_strdup(irc->sendbuffer + n); 686 g_free(irc->sendbuffer); 687 irc->sendbuffer = s; 674 g_string_erase(irc->sendbuffer, 0, n); 688 675 } 689 676 /* Otherwise something went wrong and we don't currently care … … 702 689 b_event_remove(irc->w_watch_source_id); 703 690 irc->w_watch_source_id = 0; 704 g_free(irc->sendbuffer); 705 irc->sendbuffer = NULL; 691 g_string_truncate(irc->sendbuffer, 0); 706 692 } 707 693 -
irc.h
rb9d1fdc r7de07a0 85 85 double last_pong; 86 86 int pinging; 87 char*sendbuffer;87 GString *sendbuffer; 88 88 char *readbuffer; 89 89 GIConv iconv, oconv; -
unix.c
rb9d1fdc r7de07a0 373 373 sock_make_blocking(irc->fd); 374 374 if (irc->sendbuffer) { 375 (void) write(irc->fd, irc->sendbuffer , strlen(irc->sendbuffer));375 (void) write(irc->fd, irc->sendbuffer->str, irc->sendbuffer->len); 376 376 } 377 377 (void) write(irc->fd, message, sizeof(message) - 1);
Note: See TracChangeset
for help on using the changeset viewer.