Skip to content

Commit d0be389

Browse files
committed
Always set the NOSIGNAL option
According to libcurl's thread safety docs [1]: > When using multiple threads you should set the CURLOPT_NOSIGNAL > option to 1L for all handles This library is likely to be used in a multithreaded situation, so set this option as such. The implication of this is that timeouts are not honored during the DNS lookup phase, but using c-ares can fix that and it seems a small price to pay for thread safety! [1]: http://curl.haxx.se/libcurl/c/threadsafe.html Closes #97
1 parent 7a154b2 commit d0be389

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/http/handle.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,19 @@ impl<'a, 'b> Request<'a, 'b> {
386386
try!(handle.easy.setopt(opt::HTTPHEADER, &ffi_headers));
387387
}
388388

389+
// According to libcurl's thread safety docs [1]:
390+
//
391+
// > When using multiple threads you should set the CURLOPT_NOSIGNAL
392+
// > option to 1L for all handles
393+
//
394+
// This library is likely to be used in a multithreaded situation, so
395+
// set this option as such. The implication of this is that timeouts are
396+
// not honored during the DNS lookup phase, but using c-ares can fix
397+
// that and it seems a small price to pay for thread safety!
398+
//
399+
// [1]: http://curl.haxx.se/libcurl/c/threadsafe.html
400+
try!(handle.easy.setopt(opt::NOSIGNAL, 1));
401+
389402
handle.easy.perform(body.as_mut(), progress)
390403
}
391404
}

0 commit comments

Comments
 (0)