Mercurial > pidgin.yaz
diff libgaim/protocols/oscar/peer_proxy.c @ 15195:4934e7a03a98
[gaim-migrate @ 17983]
Move away from using MSG_PEEK when recv'ing data over oscar sockets.
It's possible this was causing problems with a small number of
Windows users? People seem to frown pretty heavily upon MSG_PEEK
in general, for some reason.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Wed, 13 Dec 2006 10:11:31 +0000 |
parents | cde909b9eb4b |
children |
line wrap: on
line diff
--- a/libgaim/protocols/oscar/peer_proxy.c Wed Dec 13 08:45:57 2006 +0000 +++ b/libgaim/protocols/oscar/peer_proxy.c Wed Dec 13 10:11:31 2006 +0000 @@ -203,7 +203,6 @@ { PeerConnection *conn; ssize_t read; - guint8 header[12]; ProxyFrame *frame; conn = data; @@ -212,8 +211,9 @@ /* Start reading a new proxy frame */ if (frame == NULL) { - /* Peek at the first 12 bytes to get the length */ - read = recv(conn->fd, &header, 12, MSG_PEEK); + /* Read the first 12 bytes (frame length and header) */ + read = recv(conn->fd, conn->proxy_header + conn->proxy_header_received, + 12 - conn->proxy_header_received, 0); /* Check if the proxy server closed the connection */ if (read == 0) @@ -238,30 +238,28 @@ conn->lastactivity = time(NULL); /* If we don't even have the first 12 bytes then do nothing */ - if (read < 12) + conn->proxy_header_received += read; + if (conn->proxy_header_received < 12) return; - /* Read the first 12 bytes (frame length and header) */ - read = recv(conn->fd, &header, 12, 0); - /* We only support a specific version of the proxy protocol */ - if (aimutil_get16(&header[2]) != PEER_PROXY_PACKET_VERSION) + if (aimutil_get16(&conn->proxy_header[2]) != PEER_PROXY_PACKET_VERSION) { gaim_debug_warning("oscar", "Expected peer proxy protocol " "version %u but received version %u. Closing " "connection.\n", PEER_PROXY_PACKET_VERSION, - aimutil_get16(&header[2])); + aimutil_get16(&conn->proxy_header[2])); peer_connection_trynext(conn); return; } /* Initialize a new temporary ProxyFrame for incoming data */ frame = g_new0(ProxyFrame, 1); - frame->payload.len = aimutil_get16(&header[0]) - 10; - frame->version = aimutil_get16(&header[2]); - frame->type = aimutil_get16(&header[4]); - frame->unknown = aimutil_get16(&header[6]); - frame->flags = aimutil_get16(&header[10]); + frame->payload.len = aimutil_get16(&conn->proxy_header[0]) - 10; + frame->version = aimutil_get16(&conn->proxy_header[2]); + frame->type = aimutil_get16(&conn->proxy_header[4]); + frame->unknown = aimutil_get16(&conn->proxy_header[6]); + frame->flags = aimutil_get16(&conn->proxy_header[10]); if (frame->payload.len > 0) frame->payload.data = g_new(guint8, frame->payload.len); conn->frame = frame; @@ -313,8 +311,11 @@ conn->frame = NULL; byte_stream_rewind(&frame->payload); peer_proxy_recv_frame(conn, frame); + g_free(frame->payload.data); g_free(frame); + + conn->proxy_header_received = 0; } /**