summaryrefslogtreecommitdiff
path: root/perlio.c
diff options
context:
space:
mode:
authorAndy Lester <andy@petdance.com>2006-04-03 03:28:18 -0500
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2006-04-04 08:54:05 +0000
commit6b4ce6c8aaed4a52bfca44a2e7fa0e1adbf47887 (patch)
tree6a9c5ace8aa59677d8e4edc79ecaf5a12e413ae1 /perlio.c
parentcb8845025fc6f1183f7120c6693dc548500a18f1 (diff)
downloadperl-6b4ce6c8aaed4a52bfca44a2e7fa0e1adbf47887.tar.gz
Move conditional SOCKS5 code into #ifdefs
Message-ID: <20060403132818.GA7820@petdance.com> p4raw-id: //depot/perl@27709
Diffstat (limited to 'perlio.c')
-rw-r--r--perlio.c39
1 files changed, 14 insertions, 25 deletions
diff --git a/perlio.c b/perlio.c
index 94ce1bcfa3..6398cdc809 100644
--- a/perlio.c
+++ b/perlio.c
@@ -3068,7 +3068,6 @@ PerlIOStdio_close(pTHX_ PerlIO *f)
}
else {
const int fd = fileno(stdio);
- int socksfd = 0;
int invalidate = 0;
IV result = 0;
int saveerr = 0;
@@ -3080,36 +3079,26 @@ PerlIOStdio_close(pTHX_ PerlIO *f)
*/
int optval;
Sock_size_t optlen = sizeof(int);
- if (getsockopt(fd, SOL_SOCKET, SO_TYPE, (void *) &optval, &optlen) == 0) {
- socksfd = 1;
+ if (getsockopt(fd, SOL_SOCKET, SO_TYPE, (void *) &optval, &optlen) == 0)
invalidate = 1;
- }
#endif
- if (PerlIOUnix_refcnt_dec(fd) > 0) {
- /* File descriptor still in use */
+ if (PerlIOUnix_refcnt_dec(fd) > 0) /* File descriptor still in use */
invalidate = 1;
- socksfd = 0;
- }
if (invalidate) {
- /* For STD* handles don't close the stdio at all
- this is because we have shared the FILE * too
- */
- if (stdio == stdin) {
- /* Some stdios are buggy fflush-ing inputs */
- return 0;
- }
- else if (stdio == stdout || stdio == stderr) {
- return PerlIO_flush(f);
- }
+ /* For STD* handles, don't close stdio, since we shared the FILE *, too. */
+ if (stdio == stdin) /* Some stdios are buggy fflush-ing inputs */
+ return 0;
+ if (stdio == stdout || stdio == stderr)
+ return PerlIO_flush(f);
/* Tricky - must fclose(stdio) to free memory but not close(fd)
Use Sarathy's trick from maint-5.6 to invalidate the
fileno slot of the FILE *
*/
result = PerlIO_flush(f);
saveerr = errno;
- if (!(invalidate = PerlIOStdio_invalidate_fileno(aTHX_ stdio))) {
- dupfd = PerlLIO_dup(fd);
- }
+ invalidate = PerlIOStdio_invalidate_fileno(aTHX_ stdio);
+ if (!invalidate)
+ dupfd = PerlLIO_dup(fd);
}
result = PerlSIO_fclose(stdio);
/* We treat error from stdio as success if we invalidated
@@ -3119,10 +3108,10 @@ PerlIOStdio_close(pTHX_ PerlIO *f)
errno = saveerr;
result = 0;
}
- if (socksfd) {
- /* in SOCKS case let close() determine return value */
- result = close(fd);
- }
+#ifdef SOCKS5_VERSION_NAME
+ /* in SOCKS' case, let close() determine return value */
+ result = close(fd);
+#endif
if (dupfd) {
PerlLIO_dup2(dupfd,fd);
PerlLIO_close(dupfd);