# HG changeset patch # User Ethan Blanton # Date 1308969728 0 # Node ID 54a700cedb38f6568f160bb4981d36ba16ce2198 # Parent 47c604efed32aff87d164e0d771bf4729088f91e Fix races between irc_send_raw() and normal prpl-internal sends. Fixes #14263 diff -r 47c604efed32 -r 54a700cedb38 libpurple/protocols/irc/irc.c --- a/libpurple/protocols/irc/irc.c Fri Jun 24 16:44:06 2011 +0000 +++ b/libpurple/protocols/irc/irc.c Sat Jun 25 02:42:08 2011 +0000 @@ -101,7 +101,11 @@ static int irc_send_raw(PurpleConnection *gc, const char *buf, int len) { struct irc_conn *irc = (struct irc_conn*)gc->proto_data; - return do_send(irc, buf, len); + if (len == -1) { + len = strlen(buf); + } + irc_send_len(irc, buf, len); + return len; } static void @@ -144,16 +148,18 @@ int irc_send(struct irc_conn *irc, const char *buf) { - int ret, buflen; + return irc_send_len(irc, buf, strlen(buf)); +} + +int irc_send_len(struct irc_conn *irc, const char *buf, int buflen) +{ + int ret; char *tosend= g_strdup(buf); purple_signal_emit(_irc_plugin, "irc-sending-text", purple_account_get_connection(irc->account), &tosend); if (tosend == NULL) return 0; - buflen = strlen(tosend); - - /* If we're not buffering writes, try to send immediately */ if (!irc->writeh) ret = do_send(irc, tosend, buflen); diff -r 47c604efed32 -r 54a700cedb38 libpurple/protocols/irc/irc.h --- a/libpurple/protocols/irc/irc.h Fri Jun 24 16:44:06 2011 +0000 +++ b/libpurple/protocols/irc/irc.h Sat Jun 25 02:42:08 2011 +0000 @@ -106,6 +106,7 @@ typedef int (*IRCCmdCallback) (struct irc_conn *irc, const char *cmd, const char *target, const char **args); int irc_send(struct irc_conn *irc, const char *buf); +int irc_send_len(struct irc_conn *irc, const char *buf, int len); gboolean irc_blist_timeout(struct irc_conn *irc); gboolean irc_who_channel_timeout(struct irc_conn *irc); void irc_buddy_query(struct irc_conn *irc);