Changeset c82e4ca
- Timestamp:
- 2018-07-31T03:40:26Z (6 years ago)
- Branches:
- master
- Children:
- 921ea8b, f7cc734
- Parents:
- 5c90890
- git-author:
- dequis <dx@…> (12-07-18 08:30:59)
- git-committer:
- dx <dx@…> (31-07-18 03:40:26)
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
bitlbee.c
r5c90890 rc82e4ca 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
r5c90890 rc82e4ca 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) { … … 309 311 } 310 312 311 g_ free(irc->sendbuffer);313 g_string_free(irc->sendbuffer, TRUE); 312 314 g_free(irc->readbuffer); 313 315 g_free(irc->password); … … 599 601 600 602 if (now) { 601 g_free(irc->sendbuffer); 602 irc->sendbuffer = g_strdup("\r\n"); 603 g_string_assign(irc->sendbuffer, "\r\n"); 603 604 } 604 605 irc_vawrite(temp->data, format, params); … … 615 616 void irc_vawrite(irc_t *irc, char *format, va_list params) 616 617 { 617 int size;618 618 char line[IRC_MAX_LINE + 1]; 619 619 … … 642 642 g_strlcat(line, "\r\n", IRC_MAX_LINE + 1); 643 643 644 if (irc->sendbuffer != NULL) { 645 gsize line_len = strlen(line); 646 gsize buffer_len = strlen(irc->sendbuffer); 647 648 size = buffer_len + line_len; 649 irc->sendbuffer = g_renew(char, irc->sendbuffer, size + 1); 650 strcpy((irc->sendbuffer + buffer_len), line); 651 } else { 652 irc->sendbuffer = g_strdup(line); 653 } 644 g_string_append(irc->sendbuffer, line); 654 645 655 646 if (irc->w_watch_source_id == 0) { … … 673 664 { 674 665 ssize_t n; 675 size_t len ;676 677 if ( irc->sendbuffer == NULL) {666 size_t len = irc->sendbuffer->len; 667 668 if (len == 0) { 678 669 return; 679 670 } 680 671 681 len = strlen(irc->sendbuffer); 682 if ((n = send(irc->fd, irc->sendbuffer, len, 0)) == len) { 683 g_free(irc->sendbuffer); 684 irc->sendbuffer = NULL; 672 if ((n = send(irc->fd, irc->sendbuffer->str, len, 0)) == len) { 673 g_string_truncate(irc->sendbuffer, 0); 685 674 686 675 b_event_remove(irc->w_watch_source_id); 687 676 irc->w_watch_source_id = 0; 688 677 } else if (n > 0) { 689 char *s = g_strdup(irc->sendbuffer + n); 690 g_free(irc->sendbuffer); 691 irc->sendbuffer = s; 678 g_string_erase(irc->sendbuffer, 0, n); 692 679 } 693 680 /* Otherwise something went wrong and we don't currently care … … 706 693 b_event_remove(irc->w_watch_source_id); 707 694 irc->w_watch_source_id = 0; 708 g_free(irc->sendbuffer); 709 irc->sendbuffer = NULL; 695 g_string_truncate(irc->sendbuffer, 0); 710 696 } 711 697 -
irc.h
r5c90890 rc82e4ca 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
r5c90890 rc82e4ca 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.