/pidgin/main: ef1519ab5f2c: Merged in xhaakon/pidgin (pull reque...
Gary Kramlich
grim at reaperworld.com
Mon Apr 18 22:54:56 EDT 2016
Changeset: ef1519ab5f2cf48f984154f5dbaf62d3218ee83c
Author: Gary Kramlich <grim at reaperworld.com>
Date: 2016-04-18 21:54 -0500
Branch: default
URL: https://hg.pidgin.im/pidgin/main/rev/ef1519ab5f2c
Description:
Merged in xhaakon/pidgin (pull request #37)
Fix purple_xfer_write() during do_transfer()
diffstat:
libpurple/xfer.c | 41 ++++++++++++++++++++++++++---------------
1 files changed, 26 insertions(+), 15 deletions(-)
diffs (65 lines):
diff --git a/libpurple/xfer.c b/libpurple/xfer.c
--- a/libpurple/xfer.c
+++ b/libpurple/xfer.c
@@ -1205,27 +1205,38 @@ purple_xfer_read(PurpleXfer *xfer, gucha
return r;
}
+static gssize
+do_write(PurpleXfer *xfer, const guchar *buffer, gsize size)
+{
+ PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer);
+ gssize r;
+
+ g_return_val_if_fail(priv != NULL, 0);
+ g_return_val_if_fail(buffer != NULL, 0);
+ g_return_val_if_fail(size != 0, 0);
+
+ if (priv->ops.write != NULL) {
+ r = (priv->ops.write)(buffer, size, xfer);
+ } else {
+ r = write(priv->fd, buffer, size);
+ if (r < 0 && errno == EAGAIN)
+ r = 0;
+ }
+
+ return r;
+}
+
gssize
purple_xfer_write(PurpleXfer *xfer, const guchar *buffer, gsize size)
{
PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer);
- gssize r, s;
-
- g_return_val_if_fail(priv != NULL, 0);
- g_return_val_if_fail(buffer != NULL, 0);
- g_return_val_if_fail(size != 0, 0);
+ gssize s;
+
+ g_return_val_if_fail(priv != NULL, 0);
s = MIN((gssize)purple_xfer_get_bytes_remaining(xfer), (gssize)size);
- if (priv->ops.write != NULL) {
- r = (priv->ops.write)(buffer, s, xfer);
- } else {
- r = write(priv->fd, buffer, s);
- if (r < 0 && errno == EAGAIN)
- r = 0;
- }
-
- return r;
+ return do_write(xfer, buffer, s);
}
gboolean
@@ -1405,7 +1416,7 @@ do_transfer(PurpleXfer *xfer)
result = priv->buffer->len;
}
- r = purple_xfer_write(xfer, buffer, result);
+ r = do_write(xfer, buffer, result);
if (r == -1) {
purple_xfer_cancel_remote(xfer);
More information about the Commits
mailing list