> Log Message: > Patch #1003700: Add socketpair function to socket module. > > Index: socketmodule.c > + #ifdef HAVE_SOCKETPAIR > + /* Create a pair of sockets using the socketpair() function. > + Arguments as for socket(). */ > + > + /*ARGSUSED*/ > + static PyObject * > + socket_socketpair(PyObject *self, PyObject *args) > + { > + PySocketSockObject *s0 = NULL, *s1 = NULL; > + SOCKET_T sv[2]; > + int family, type = SOCK_STREAM, proto = 0; > + PyObject *res = NULL; > + > + #if defined(AF_UNIX) > + family = AF_UNIX; > + #else > + family = AF_INET; > + #endif The docstring (below) states the arguments are the same as socket(). However, in sock_initobj() line 2496, the family is initialized to AF_INET. I think the #if defined(AF_UNIX) code above should be removed and family should be initialized to AF_INET. I didn't look to see if the documentation agrees with the docstring. > + if (!PyArg_ParseTuple(args, "|iii:socketpair", > + &family, &type, &proto)) > + return NULL; > + /* Create a pair of socket fds */ > + if (socketpair(family, type, proto, sv) < 0) > + return set_error(); > + #ifdef SIGPIPE > + (void) signal(SIGPIPE, SIG_IGN); > + #endif I don't think the #ifdef SIGPIPE code is correct. If the user installed a signal handler calling signal() will remove it. I think the call to signal() should be removed. Neal > + s0 = new_sockobject(sv[0], family, type, proto); > + if (s0 == NULL) > + goto finally; > + s1 = new_sockobject(sv[1], family, type, proto); > + if (s1 == NULL) > + goto finally; > + res = PyTuple_Pack(2, s0, s1); > + > + finally: > + if (res == NULL) { > + if (s0 == NULL) > + SOCKETCLOSE(sv[0]); > + if (s1 == NULL) > + SOCKETCLOSE(sv[1]); > + } > + Py_XDECREF(s0); > + Py_XDECREF(s1); > + return res; > + } > + > + PyDoc_STRVAR(socketpair_doc, > + "socketpair([family[, type[, proto]]]) -> (socket object, socket object)\n\ > + \n\ > + Create a pair of socket objects from the sockets returned by the platform\n\ > + socketpair() function.\n\ > + The arguments are the same as for socket()."); > + > + #endif /* HAVE_SOCKETPAIR */
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4