Skip to content

Commit 7028b09

Browse files
authored
Merge pull request #2529 from millenomi/sr-11557
master: Cherry-pick revert of 02656bf
2 parents f62c026 + 8821c89 commit 7028b09

File tree

4 files changed

+3
-38
lines changed

4 files changed

+3
-38
lines changed

CoreFoundation/URL.subproj/CFURLSessionInterface.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,6 @@ CFURLSessionEasyCode CFURLSession_easy_setopt_tc(CFURLSessionEasyHandle _Nonnull
110110
return MakeEasyCode(curl_easy_setopt(curl, option.value, a));
111111
}
112112

113-
CFURLSessionEasyCode CFURLSession_easy_setopt_csf(CFURLSessionEasyHandle _Nonnull curl, CFURLSessionOption option, int (*_Nonnull a)(void *_Nullable clientp, CFURLSession_socket_t)) {
114-
return MakeEasyCode(curl_easy_setopt(curl, option.value, a));
115-
}
116-
117113
CFURLSessionEasyCode CFURLSession_easy_getinfo_long(CFURLSessionEasyHandle _Nonnull curl, CFURLSessionInfo info, long *_Nonnull a) {
118114
return MakeEasyCode(curl_easy_getinfo(curl, info.value, a));
119115
}

CoreFoundation/URL.subproj/CFURLSessionInterface.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ CF_EXPORT CFURLSessionMultiCode CFURLSession_multi_setopt_ptr(CFURLSessionMultiH
601601
CF_EXPORT CFURLSessionMultiCode CFURLSession_multi_setopt_l(CFURLSessionMultiHandle _Nonnull multi_handle, CFURLSessionMultiOption option, long a);
602602
CF_EXPORT CFURLSessionMultiCode CFURLSession_multi_setopt_sf(CFURLSessionMultiHandle _Nonnull multi_handle, CFURLSessionMultiOption option, int (*_Nonnull a)(CFURLSessionEasyHandle _Nonnull, CFURLSession_socket_t, int, void *_Nullable, void *_Nullable));
603603
CF_EXPORT CFURLSessionMultiCode CFURLSession_multi_setopt_tf(CFURLSessionMultiHandle _Nonnull multi_handle, CFURLSessionMultiOption option, int (*_Nonnull a)(CFURLSessionMultiHandle _Nonnull, long, void *_Nullable));
604-
CF_EXPORT CFURLSessionEasyCode CFURLSession_easy_setopt_csf(CFURLSessionEasyHandle _Nonnull curl, CFURLSessionOption option, int (*_Nonnull a)(void* _Nullable clientp, CFURLSession_socket_t));
604+
605605
CF_EXPORT CFURLSessionEasyCode CFURLSessionInit(void);
606606

607607

Foundation/URLSession/libcurl/EasyHandle.swift

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -486,14 +486,6 @@ fileprivate extension _EasyHandle {
486486
return 1
487487
}
488488
}.asError()
489-
490-
try! CFURLSession_easy_setopt_csf(rawHandle, CFURLSessionOptionCLOSESOCKETFUNCTION) { (clientp: UnsafeMutableRawPointer?, socket: CFURLSession_socket_t) -> Int32 in
491-
// Don't let CURL close the socket here because the
492-
// dispatch sources are associated with it and we need to
493-
// cancel them before closing the file descriptor.
494-
return 0
495-
}.asError()
496-
497489
// seeking in input stream
498490
try! CFURLSession_easy_setopt_ptr(rawHandle, CFURLSessionOptionSEEKDATA, UnsafeMutableRawPointer(Unmanaged.passUnretained(self).toOpaque())).asError()
499491
try! CFURLSession_easy_setopt_seek(rawHandle, CFURLSessionOptionSEEKFUNCTION, { (userdata, offset, origin) -> Int32 in

Foundation/URLSession/libcurl/MultiHandle.swift

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,7 @@ fileprivate extension URLSession._MultiHandle {
122122
} else if socketSources != nil && action == .unregister {
123123
// We need to release the stored pointer:
124124
if let opaque = socketSourcePtr {
125-
let s: Unmanaged<_SocketSources> = Unmanaged<_SocketSources>.fromOpaque(opaque)
126-
s.takeUnretainedValue().tearDown(socket: socket, queue: queue)
127-
s.release()
125+
Unmanaged<_SocketSources>.fromOpaque(opaque).release()
128126
}
129127
socketSources = nil
130128
}
@@ -409,7 +407,6 @@ fileprivate extension URLSession._MultiHandle._Timeout {
409407
fileprivate class _SocketSources {
410408
var readSource: DispatchSource?
411409
var writeSource: DispatchSource?
412-
let activeSockets = DispatchGroup()
413410

414411
func createReadSource(socket: CFURLSession_socket_t, queue: DispatchQueue, handler: DispatchWorkItem) {
415412
guard readSource == nil else { return }
@@ -418,13 +415,7 @@ fileprivate class _SocketSources {
418415
#else
419416
let s = DispatchSource.makeReadSource(fileDescriptor: socket, queue: queue)
420417
#endif
421-
activeSockets.enter()
422418
s.setEventHandler(handler: handler)
423-
s.setCancelHandler(handler: DispatchWorkItem { [weak self] in
424-
guard let self = self else { return }
425-
self.activeSockets.leave()
426-
})
427-
428419
readSource = s as? DispatchSource
429420
s.resume()
430421
}
@@ -436,26 +427,12 @@ fileprivate class _SocketSources {
436427
#else
437428
let s = DispatchSource.makeWriteSource(fileDescriptor: socket, queue: queue)
438429
#endif
439-
activeSockets.enter()
440-
s.setCancelHandler(handler: DispatchWorkItem { [weak self] in
441-
guard let self = self else { return }
442-
self.activeSockets.leave()
443-
})
444430
s.setEventHandler(handler: handler)
445431
writeSource = s as? DispatchSource
446432
s.resume()
447433
}
448434

449-
func tearDown(socket: CFURLSession_socket_t, queue: DispatchQueue) {
450-
activeSockets.notify(queue: queue) {
451-
withExtendedLifetime(self) {
452-
#if os(Windows)
453-
closesocket(socket)
454-
#else
455-
close(socket)
456-
#endif
457-
}
458-
}
435+
func tearDown() {
459436
if let s = readSource {
460437
s.cancel()
461438
}

0 commit comments

Comments
 (0)