curl-library
Obscure internal select() problem on Win32/Visual Studio 2015 (cmake) build
Date: Fri, 28 Jul 2017 11:01:11 +0200
Hi,
we are using libcurl in an application that uses a big bunch of REST API calls 
(through either HTTP or HTTPs). There is a situation where I do a FORM 
multipart upload of a bigger file (>4MB) that fails sometimes.
I first thought it would have to do with Expect: 100-continue but after I 
disabled this the symptoms kept the same.
This is what I get with wireshark:
(First packet to server @49.441763s):
0000   e0 69 95 03 31 fb 50 26 90 19 18 35 08 00 45 00  .i..1.P&...5..E.
0010   01 6b 6f db 40 00 80 06 e7 3e c0 a8 10 a3 c0 a8  .ko.@....>......
0020   10 7f ed f8 1f 92 cc a7 53 4e 57 70 25 a9 50 18  ........SNWp%.P.
0030   08 05 42 ae 00 00 50 4f 53 54 20 2f 64 69 61 67  ..B...POST /diag
0040   2f 72 65 73 74 2f 76 31 2f 66 69 6c 65 20 48 54  /rest/v1/file HT
0050   54 50 2f 31 2e 31 0d 0a 48 6f 73 74 3a 20 74 6e  TP/1.1..Host: tn
0060   74 3a 38 30 38 32 0d 0a 41 63 63 65 70 74 3a 20  t:8082..Accept: 
0070   2a 2f 2a 0d 0a 43 6f 6e 6e 65 63 74 69 6f 6e 3a  */*..Connection:
0080   20 55 70 67 72 61 64 65 2c 20 48 54 54 50 32 2d   Upgrade, HTTP2-
0090   53 65 74 74 69 6e 67 73 0d 0a 55 70 67 72 61 64  Settings..Upgrad
00a0   65 3a 20 68 32 63 0d 0a 48 54 54 50 32 2d 53 65  e: h2c..HTTP2-Se
00b0   74 74 69 6e 67 73 3a 20 41 41 4d 41 41 41 42 6b  ttings: AAMAAABk
00c0   41 41 52 41 41 41 41 41 41 41 49 41 41 41 41 41  AARAAAAAAAIAAAAA
00d0   0d 0a 43 6f 6f 6b 69 65 3a 20 4a 53 45 53 53 49  ..Cookie: JSESSI
00e0   4f 4e 49 44 3d 37 33 42 31 46 30 37 37 43 37 45  ONID=73B1F077C7E
00f0   39 43 46 45 43 44 31 33 45 42 39 36 38 46 36 30  9CFECD13EB968F60
0100   33 43 35 43 35 0d 0a 43 6f 6e 74 65 6e 74 2d 4c  3C5C5..Content-L
0110   65 6e 67 74 68 3a 20 32 34 35 39 32 36 35 32 0d  ength: 24592652.
0120   0a 43 6f 6e 74 65 6e 74 2d 54 79 70 65 3a 20 6d  .Content-Type: m
0130   75 6c 74 69 70 61 72 74 2f 66 6f 72 6d 2d 64 61  ultipart/form-da
0140   74 61 3b 20 62 6f 75 6e 64 61 72 79 3d 2d 2d 2d  ta; boundary=---
0150   2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0160   2d 2d 2d 2d 2d 38 62 37 66 35 38 66 39 63 30 66  -----8b7f58f9c0f
0170   33 32 66 36 39 0d 0a 0d 0a                       32f69....
(Second packet to server @49.441826s):
0000   e0 69 95 03 31 fb 50 26 90 19 18 35 08 00 45 00  .i..1.P&...5..E.
0010   01 65 6f dc 40 00 80 06 e7 43 c0 a8 10 a3 c0 a8  .eo.@....C......
0020   10 7f ed f8 1f 92 cc a7 54 91 57 70 25 a9 50 18  ........T.Wp%.P.
0030   08 05 1e ce 00 00 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ......----------
0040   2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0050   38 62 37 66 35 38 66 39 63 30 66 33 32 66 36 39  8b7f58f9c0f32f69
0060   0d 0a 43 6f 6e 74 65 6e 74 2d 44 69 73 70 6f 73  ..Content-Dispos
0070   69 74 69 6f 6e 3a 20 66 6f 72 6d 2d 64 61 74 61  ition: form-data
0080   3b 20 6e 61 6d 65 3d 22 65 76 61 6c 75 61 74 69  ; name="evaluati
0090   6f 6e 22 0d 0a 0d 0a 33 0d 0a 2d 2d 2d 2d 2d 2d  on"....3..------
00a0   2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
00b0   2d 2d 2d 2d 38 62 37 66 35 38 66 39 63 30 66 33  ----8b7f58f9c0f3
00c0   32 66 36 39 0d 0a 43 6f 6e 74 65 6e 74 2d 44 69  2f69..Content-Di
00d0   73 70 6f 73 69 74 69 6f 6e 3a 20 66 6f 72 6d 2d  sposition: form-
00e0   64 61 74 61 3b 20 6e 61 6d 65 3d 22 65 76 61 6c  data; name="eval
00f0   75 61 74 69 6f 6e 54 79 70 65 22 0d 0a 0d 0a 48  uationType"....H
0100   4f 4c 54 45 52 0d 0a 2d 2d 2d 2d 2d 2d 2d 2d 2d  OLTER..---------
0110   2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0120   2d 38 62 37 66 35 38 66 39 63 30 66 33 32 66 36  -8b7f58f9c0f32f6
0130   39 0d 0a 43 6f 6e 74 65 6e 74 2d 44 69 73 70 6f  9..Content-Dispo
0140   73 69 74 69 6f 6e 3a 20 66 6f 72 6d 2d 64 61 74  sition: form-dat
0150   61 3b 20 6e 61 6d 65 3d 22 66 69 6c 65 22 3b 20  a; name="file"; 
0160   66 69 6c 65 6e 61 6d 65 3d 22 64 61 74 61 22 0d  filename="data".
0170   0a 0d 0a                                         ...
Then comes an ack from the server @49.442211s
Then nothing...
After 20s the server says "Bad Request":
0000   50 26 90 19 18 35 e0 69 95 03 31 fb 08 00 45 00  P&...5.i..1...E.
0010   01 03 ad 2c 40 00 3f 06 eb 55 c0 a8 10 7f c0 a8  ...,@.?..U......
0020   10 a3 1f 92 ed f8 57 70 25 a9 cc a7 55 ce 50 18  ......Wp%...U.P.
0030   60 00 95 50 00 00 48 54 54 50 2f 31 2e 31 20 34  `..P..HTTP/1.1 4
0040   30 30 20 42 61 64 20 52 65 71 75 65 73 74 0d 0a  00 Bad Request..
0050   53 65 72 76 65 72 3a 20 41 70 61 63 68 65 2d 43  Server: Apache-C
0060   6f 79 6f 74 65 2f 31 2e 31 0d 0a 43 61 63 68 65  oyote/1.1..Cache
0070   2d 43 6f 6e 74 72 6f 6c 3a 20 6e 6f 2d 63 61 63  -Control: no-cac
0080   68 65 0d 0a 43 6f 6e 74 65 6e 74 2d 54 79 70 65  he..Content-Type
0090   3a 20 74 65 78 74 2f 68 74 6d 6c 3b 63 68 61 72  : text/html;char
00a0   73 65 74 3d 75 74 66 2d 38 0d 0a 43 6f 6e 74 65  set=utf-8..Conte
00b0   6e 74 2d 4c 61 6e 67 75 61 67 65 3a 20 65 6e 0d  nt-Language: en.
00c0   0a 43 6f 6e 74 65 6e 74 2d 4c 65 6e 67 74 68 3a  .Content-Length:
00d0   20 31 30 33 33 0d 0a 44 61 74 65 3a 20 46 72 69   1033..Date: Fri
00e0   2c 20 32 38 20 4a 75 6c 20 32 30 31 37 20 30 38  , 28 Jul 2017 08
00f0   3a 35 34 3a 31 33 20 47 4d 54 0d 0a 43 6f 6e 6e  :54:13 GMT..Conn
0100   65 63 74 69 6f 6e 3a 20 63 6c 6f 73 65 0d 0a 0d  ection: close...
0110   0a                                               .
and the transfer is finished on curl's side.
Interestingly, it is the most time in select.c function Curl_poll in line 515 
doing a select. The select returns after the 1s timeout with return value of 
0. So I think it just thinks that nothing happened (I guess it waits for the 
write file descriptor to be set?).
Any idea what's wrong here? Could it be a race condition on non-blocking 
writes that happen sometime?
Thanks for your help,
David
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:   https://curl.haxx.se/mail/etiquette.html
Received on 2017-07-28