mirror of
https://github.com/curl/curl.git
synced 2026-05-13 10:56:19 +03:00
curl: limit Windows-specific code to Windows builds, other tidy-ups
Prior to this patch, some Windows logic, including a Windows-specific
warning message was compiled in for all platforms.
Also:
- fix double space in warning message on UWP.
- formatting.
Follow-up to 9a2663322c #17572
Closes #20213
This commit is contained in:
parent
470e26ff6e
commit
df7718b5cf
2 changed files with 15 additions and 12 deletions
|
|
@ -113,13 +113,14 @@ size_t tool_read_cb(char *buffer, size_t sz, size_t nmemb, void *userdata)
|
|||
#endif
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
/* If we are on Windows, and using `-T .`, then per->infd points to a socket
|
||||
connected to stdin via a reader thread, and needs to be read with recv()
|
||||
Make sure we are in non-blocking mode and infd is not regular stdin
|
||||
On Linux per->infd should be stdin (0) and the block below should not
|
||||
execute */
|
||||
if(per->uploadfile && !strcmp(per->uploadfile, ".") && per->infd > 0) {
|
||||
#if defined(_WIN32) && !defined(CURL_WINDOWS_UWP)
|
||||
#ifndef CURL_WINDOWS_UWP
|
||||
rc = recv(per->infd, buffer, curlx_uztosi(sz * nmemb), 0);
|
||||
if(rc < 0) {
|
||||
if(SOCKERRNO == SOCKEWOULDBLOCK) {
|
||||
|
|
@ -131,11 +132,13 @@ size_t tool_read_cb(char *buffer, size_t sz, size_t nmemb, void *userdata)
|
|||
rc = 0;
|
||||
}
|
||||
#else
|
||||
warnf("per->infd != 0: FD == %d. This behavior"
|
||||
" is only supported on desktop Windows", per->infd);
|
||||
warnf("per->infd != 0: FD == %d. "
|
||||
"This behavior is only supported on desktop Windows", per->infd);
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
else
|
||||
#endif
|
||||
{
|
||||
rc = read(per->infd, buffer, sz * nmemb);
|
||||
if(rc < 0) {
|
||||
if(errno == EAGAIN) {
|
||||
|
|
@ -147,6 +150,7 @@ size_t tool_read_cb(char *buffer, size_t sz, size_t nmemb, void *userdata)
|
|||
rc = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if((per->uploadfilesize != -1) &&
|
||||
(per->uploadedsofar + rc > per->uploadfilesize)) {
|
||||
/* do not allow uploading more than originally set out to do */
|
||||
|
|
|
|||
|
|
@ -607,22 +607,21 @@ static CURLcode post_per_transfer(struct per_transfer *per,
|
|||
if(!curl || !config)
|
||||
return result;
|
||||
|
||||
#ifdef _WIN32
|
||||
if(per->uploadfile) {
|
||||
if(!strcmp(per->uploadfile, ".") && per->infd > 0) {
|
||||
#if defined(_WIN32) && !defined(CURL_WINDOWS_UWP)
|
||||
#ifndef CURL_WINDOWS_UWP
|
||||
sclose(per->infd);
|
||||
#else
|
||||
warnf("Closing per->infd != 0: FD == "
|
||||
"%d. This behavior is only supported on desktop "
|
||||
" Windows", per->infd);
|
||||
warnf("Closing per->infd != 0: FD == %d. "
|
||||
"This behavior is only supported on desktop Windows", per->infd);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(per->infdopen) {
|
||||
else
|
||||
#endif
|
||||
if(per->infdopen)
|
||||
close(per->infd);
|
||||
}
|
||||
}
|
||||
|
||||
if(per->skip)
|
||||
goto skip;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue