Merge lp:~oxan/gearman.net/bugfix into lp:gearman.net

Proposed by Oxan van Leeuwen on 2010-09-01
Status: Approved
Approved by: John Ewart on 2010-09-08
Approved revision: 24
Proposed branch: lp:~oxan/gearman.net/bugfix
Merge into: lp:gearman.net
Diff against target: 22 lines (+4/-1)
1 file modified
src/Connection.cs (+4/-1)
To merge this branch: bzr merge lp:~oxan/gearman.net/bugfix
Reviewer Review Type Date Requested Status
John Ewart 2010-09-01 Pending
Review via email: mp+34336@code.launchpad.net

Description of the change

Use incremental receiving. Socket.Receive doesn't guarant that it reads all bytes you specify, it just reads at least 1 byte. If the payload is big, we need to call Receive multiple times to read the whole payload.

To post a comment you must log in.

Unmerged revisions

24. By Oxan van Leeuwen on 2010-09-01

Use incremental receiving. Socket.Receive doesn't guarant that it reads all bytes you specify, it just reads at least 1 byte. If the payload is big, we need to call Receive multiple times to read the whole payload.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Connection.cs'
2--- src/Connection.cs 2009-12-18 16:00:24 +0000
3+++ src/Connection.cs 2010-09-01 20:31:48 +0000
4@@ -113,6 +113,7 @@
5 {
6 int messagesize = -1;
7 int messagetype = -1;
8+ int read = 0;
9
10 // Initialize to 12 bytes (header only), and resize later as needed
11 byte[] header = new byte[12];
12@@ -144,7 +145,9 @@
13 Array.Copy(header, packet, header.Length);
14
15 // Receive the remainder of the message
16- conn.Receive(packet, 12, messagesize, 0);
17+ do {
18+ read += conn.Receive(packet, 12 + read, messagesize - read, 0);
19+ } while(read < messagesize);
20 } else {
21 packet = header;
22 }

Subscribers

People subscribed via source and target branches