Hi.
I have this problem with my handler being called endlessly if the socket was closed in some (I guess), unfriendly way on the remote side.
My logic, in general, is to always set *upload_data_size to 0, and return MHD_YES. In this case, I see myself being called over and over again. There are at least 3 active context (I print its %p)
The strace shows this in the loop (the write is the output from my handler, *upload_data_size is always 0 at the time of the callback)
907 poll([{fd=5, events=POLLIN}, {fd=16, events=0}, {fd=15, events=0}, {fd=14, events=0}], 4, 4294967295) = 1 ([{fd=15, revents=POLLERR|POLLHUP}])
907 write(2, "HTTP POST /r/0/0, 0 bytes, (nil)"..., 52) = 52
907 write(2, "Skipping input chunk 0, because "..., 58) = 58
907 write(2, "HTTP POST /r/0/0, 0 bytes, (nil)"..., 52) = 52
907 write(2, "Skipping input chunk 0, because "..., 58) = 58
907 write(2, "HTTP POST /r/0/0, 0 bytes, (nil)"..., 52) = 52
907 write(2, "Skipping input chunk 0, because "..., 58) = 58
Pawel.