Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2001-04-03 06:53:25 +0400
committerChristopher Faylor <me@cgf.cx>2001-04-03 06:53:25 +0400
commitc90e420d91e48a2d1e300042b3c02ab3f9690835 (patch)
tree5311093e3f1b32cae0d4c1e1c62b2d48ac20778d /winsup/cygwin/net.cc
parentbe61cf4d0ce1a34c555b96f42809c3f504bafeab (diff)
* cygrun.c (main): Fix compiler warning.
* gmon.c (_mcleanup): Ditto. * profil.c (profile_off): Ditto. * net.cc (find_winsock_errno): New function. (__set_winsock_errno): Use find_winsock_errno. (cygwin_setsockopt): Detect SO_ERROR for debugging. (cygwin_getsockopt): Ditto. Translate error when getsockopt returns SO_ERROR. * winsup.h: regparmize __set_winsock_errno. * include/sys/strace.h: Document that strace functions can't use regparm.
Diffstat (limited to 'winsup/cygwin/net.cc')
-rw-r--r--winsup/cygwin/net.cc42
1 files changed, 26 insertions, 16 deletions
diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc
index eaeef5e5d..5f10a68b0 100644
--- a/winsup/cygwin/net.cc
+++ b/winsup/cygwin/net.cc
@@ -247,26 +247,24 @@ static struct tl errmap[] =
{0, NULL, 0}
};
+static int
+find_winsock_errno (int why)
+{
+ for (int i = 0; errmap[i].w != 0; ++i)
+ if (why == errmap[i].w)
+ return errmap[i].e;
+
+ return EPERM;
+}
+
/* Cygwin internal */
void
__set_winsock_errno (const char *fn, int ln)
{
- int i;
- int why = WSAGetLastError ();
- for (i = 0; errmap[i].w != 0; ++i)
- if (why == errmap[i].w)
- break;
-
- if (errmap[i].w != 0)
- {
- syscall_printf ("%s:%d - %d (%s) -> %d", fn, ln, why, errmap[i].s, errmap[i].e);
- set_errno (errmap[i].e);
- }
- else
- {
- syscall_printf ("%s:%d - unknown error %d", fn, ln, why);
- set_errno (EPERM);
- }
+ DWORD werr = WSAGetLastError ();
+ int err = find_winsock_errno (werr);
+ set_errno (err);
+ syscall_printf ("%s:%d - winsock error %d -> errno %d", fn, ln, werr, err);
}
/*
@@ -524,6 +522,9 @@ cygwin_setsockopt (int fd,
case SO_OOBINLINE:
name="SO_OOBINLINE";
break;
+ case SO_ERROR:
+ name="SO_ERROR";
+ break;
}
res = setsockopt (h->get_socket (), level, optname,
@@ -584,11 +585,20 @@ cygwin_getsockopt (int fd,
case SO_OOBINLINE:
name="SO_OOBINLINE";
break;
+ case SO_ERROR:
+ name="SO_ERROR";
+ break;
}
res = getsockopt (h->get_socket (), level, optname,
(char *) optval, (int *) optlen);
+ if (optname == SO_ERROR)
+ {
+ int *e = (int *) optval;
+ *e = find_winsock_errno (*e);
+ }
+
if (res)
set_winsock_errno ();
}