diff options
author | Stefan Metzmacher <metze@samba.org> | 2009-04-03 17:29:12 +0200 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2009-05-01 17:38:21 +0200 |
commit | 9dbb535aa5d79a748874d1a85ef8cb6f6b195e52 (patch) | |
tree | 879b5d01757ec9aae17d2a3e23752dca2320dc88 /lib/tsocket/tsocket_helpers.c | |
parent | 5604e8d614c938876b0a8cbc6f8c38262588f961 (diff) | |
download | samba-9dbb535aa5d79a748874d1a85ef8cb6f6b195e52.tar.gz |
tsocket: remove tsocket_context related stuff
It will be replaced by tdgram_context and tstream_context.
metze
Diffstat (limited to 'lib/tsocket/tsocket_helpers.c')
-rw-r--r-- | lib/tsocket/tsocket_helpers.c | 121 |
1 files changed, 0 insertions, 121 deletions
diff --git a/lib/tsocket/tsocket_helpers.c b/lib/tsocket/tsocket_helpers.c index b2edf43d97..303be2de11 100644 --- a/lib/tsocket/tsocket_helpers.c +++ b/lib/tsocket/tsocket_helpers.c @@ -27,49 +27,6 @@ #include "tsocket.h" #include "tsocket_internal.h" -int tsocket_error_from_errno(int ret, - int sys_errno, - bool *retry) -{ - *retry = false; - - if (ret >= 0) { - return 0; - } - - if (ret != -1) { - return EIO; - } - - if (sys_errno == 0) { - return EIO; - } - - if (sys_errno == EINTR) { - *retry = true; - return sys_errno; - } - - if (sys_errno == EINPROGRESS) { - *retry = true; - return sys_errno; - } - - if (sys_errno == EAGAIN) { - *retry = true; - return sys_errno; - } - -#ifdef EWOULDBLOCK - if (sys_errno == EWOULDBLOCK) { - *retry = true; - return sys_errno; - } -#endif - - return sys_errno; -} - int tsocket_simple_int_recv(struct tevent_req *req, int *perrno) { enum tevent_req_state state; @@ -97,81 +54,3 @@ int tsocket_simple_int_recv(struct tevent_req *req, int *perrno) *perrno = EIO; return -1; } - -int tsocket_common_prepare_fd(int fd, bool high_fd) -{ - int i; - int sys_errno = 0; - int fds[3]; - int num_fds = 0; - - int result, flags; - - if (fd == -1) { - return -1; - } - - /* first make a fd >= 3 */ - if (high_fd) { - while (fd < 3) { - fds[num_fds++] = fd; - fd = dup(fd); - if (fd == -1) { - sys_errno = errno; - break; - } - } - for (i=0; i<num_fds; i++) { - close(fds[i]); - } - if (fd == -1) { - errno = sys_errno; - return fd; - } - } - - /* fd should be nonblocking. */ - -#ifdef O_NONBLOCK -#define FLAG_TO_SET O_NONBLOCK -#else -#ifdef SYSV -#define FLAG_TO_SET O_NDELAY -#else /* BSD */ -#define FLAG_TO_SET FNDELAY -#endif -#endif - - if ((flags = fcntl(fd, F_GETFL)) == -1) { - goto fail; - } - - flags |= FLAG_TO_SET; - if (fcntl(fd, F_SETFL, flags) == -1) { - goto fail; - } - -#undef FLAG_TO_SET - - /* fd should be closed on exec() */ -#ifdef FD_CLOEXEC - result = flags = fcntl(fd, F_GETFD, 0); - if (flags >= 0) { - flags |= FD_CLOEXEC; - result = fcntl(fd, F_SETFD, flags); - } - if (result < 0) { - goto fail; - } -#endif - return fd; - - fail: - if (fd != -1) { - sys_errno = errno; - close(fd); - errno = sys_errno; - } - return -1; -} - |