Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(371)

Delta Between Two Patch Sets: Modules/socketmodule.c

Issue 22043: Use a monotonic clock to compute timeouts
Left Patch Set: Created 3 years, 4 months ago
Right Patch Set: Created 3 years, 2 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « Modules/gcmodule.c ('k') | Modules/timemodule.c » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 /* Socket module */ 1 /* Socket module */
2 2
3 /* 3 /*
4 4
5 This module provides an interface to Berkeley socket IPC. 5 This module provides an interface to Berkeley socket IPC.
6 6
7 Limitations: 7 Limitations:
8 8
9 - Only AF_INET, AF_INET6 and AF_UNIX address families are supported in a 9 - Only AF_INET, AF_INET6 and AF_UNIX address families are supported in a
10 portable manner, though AF_PACKET, AF_NETLINK and AF_TIPC are supported 10 portable manner, though AF_PACKET, AF_NETLINK and AF_TIPC are supported
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 } 541 }
542 542
543 return NULL; 543 return NULL;
544 } 544 }
545 545
546 /* Function to perform the setting of socket blocking mode 546 /* Function to perform the setting of socket blocking mode
547 internally. block = (1 | 0). */ 547 internally. block = (1 | 0). */
548 static int 548 static int
549 internal_setblocking(PySocketSockObject *s, int block) 549 internal_setblocking(PySocketSockObject *s, int block)
550 { 550 {
551 #ifdef MS_WINDOWS
552 u_long arg;
553 #endif
551 #if !defined(MS_WINDOWS) \ 554 #if !defined(MS_WINDOWS) \
552 && !((defined(HAVE_SYS_IOCTL_H) && defined(FIONBIO))) 555 && !((defined(HAVE_SYS_IOCTL_H) && defined(FIONBIO)))
553 int delay_flag, new_delay_flag; 556 int delay_flag, new_delay_flag;
554 #endif 557 #endif
555 #ifdef SOCK_NONBLOCK 558 #ifdef SOCK_NONBLOCK
556 if (block) 559 if (block)
557 s->sock_type &= (~SOCK_NONBLOCK); 560 s->sock_type &= (~SOCK_NONBLOCK);
558 else 561 else
559 s->sock_type |= SOCK_NONBLOCK; 562 s->sock_type |= SOCK_NONBLOCK;
560 #endif 563 #endif
561 564
562 Py_BEGIN_ALLOW_THREADS 565 Py_BEGIN_ALLOW_THREADS
563 #ifndef MS_WINDOWS 566 #ifndef MS_WINDOWS
564 #if (defined(HAVE_SYS_IOCTL_H) && defined(FIONBIO)) 567 #if (defined(HAVE_SYS_IOCTL_H) && defined(FIONBIO))
565 block = !block; 568 block = !block;
566 ioctl(s->sock_fd, FIONBIO, (unsigned int *)&block); 569 ioctl(s->sock_fd, FIONBIO, (unsigned int *)&block);
567 #else 570 #else
568 delay_flag = fcntl(s->sock_fd, F_GETFL, 0); 571 delay_flag = fcntl(s->sock_fd, F_GETFL, 0);
569 if (block) 572 if (block)
570 new_delay_flag = delay_flag & (~O_NONBLOCK); 573 new_delay_flag = delay_flag & (~O_NONBLOCK);
571 else 574 else
572 new_delay_flag = delay_flag | O_NONBLOCK; 575 new_delay_flag = delay_flag | O_NONBLOCK;
573 if (new_delay_flag != delay_flag) 576 if (new_delay_flag != delay_flag)
574 fcntl(s->sock_fd, F_SETFL, new_delay_flag); 577 fcntl(s->sock_fd, F_SETFL, new_delay_flag);
575 #endif 578 #endif
576 #else /* MS_WINDOWS */ 579 #else /* MS_WINDOWS */
577 block = !block; 580 arg = !block;
578 ioctlsocket(s->sock_fd, FIONBIO, (u_long*)&block); 581 ioctlsocket(s->sock_fd, FIONBIO, &arg);
579 #endif /* MS_WINDOWS */ 582 #endif /* MS_WINDOWS */
580 Py_END_ALLOW_THREADS 583 Py_END_ALLOW_THREADS
581 584
582 /* Since these don't return anything */ 585 /* Since these don't return anything */
583 return 1; 586 return 1;
584 } 587 }
585 588
586 /* Do a select()/poll() on the socket, if necessary (sock_timeout > 0). 589 /* Do a select()/poll() on the socket, if necessary (sock_timeout > 0).
587 The argument writing indicates the direction. 590 The argument writing indicates the direction.
588 This does not raise an exception; we'll let our caller do that 591 This does not raise an exception; we'll let our caller do that
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 Py_END_ALLOW_THREADS 669 Py_END_ALLOW_THREADS
667 if (timeout == 1) { 670 if (timeout == 1) {
668 PyErr_SetString(socket_timeout, "timed out"); 671 PyErr_SetString(socket_timeout, "timed out");
669 return -1; 672 return -1;
670 } 673 }
671 END_SELECT_LOOP(s) 674 END_SELECT_LOOP(s)
672 */ 675 */
673 676
674 #define BEGIN_SELECT_LOOP(s) \ 677 #define BEGIN_SELECT_LOOP(s) \
675 { \ 678 { \
676 _PyTime_timespec now, deadline = {0, 0}; \ 679 _PyTime_timeval now, deadline = {0, 0}; \
677 double interval = s->sock_timeout; \ 680 double interval = s->sock_timeout; \
678 int has_timeout = s->sock_timeout > 0.0; \ 681 int has_timeout = s->sock_timeout > 0.0; \
679 if (has_timeout) { \ 682 if (has_timeout) { \
680 _PyTime_monotonic(&now); \ 683 _PyTime_monotonic(&now); \
681 deadline = now; \ 684 deadline = now; \
682 _PyTime_ADD_SECONDS(deadline, s->sock_timeout); \ 685 _PyTime_ADD_SECONDS(deadline, s->sock_timeout); \
683 } \ 686 } \
684 while (1) { \ 687 while (1) { \
685 errno = 0; \ 688 errno = 0; \
686 689
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
1203 /* If we don't know the address family, don't raise an 1206 /* If we don't know the address family, don't raise an
1204 exception -- return it as an (int, bytes) tuple. */ 1207 exception -- return it as an (int, bytes) tuple. */
1205 return Py_BuildValue("iy#", 1208 return Py_BuildValue("iy#",
1206 addr->sa_family, 1209 addr->sa_family,
1207 addr->sa_data, 1210 addr->sa_data,
1208 sizeof(addr->sa_data)); 1211 sizeof(addr->sa_data));
1209 1212
1210 } 1213 }
1211 } 1214 }
1212 1215
1216 /* Helper for getsockaddrarg: bypass IDNA for ASCII-only host names
1217 (in particular, numeric IP addresses). */
1218 struct maybe_idna {
1219 PyObject *obj;
1220 char *buf;
1221 };
1222
1223 static void
1224 idna_cleanup(struct maybe_idna *data)
1225 {
1226 Py_CLEAR(data->obj);
1227 }
1228
1229 static int
1230 idna_converter(PyObject *obj, struct maybe_idna *data)
1231 {
1232 size_t len;
1233 PyObject *obj2, *obj3;
1234 if (obj == NULL) {
1235 idna_cleanup(data);
1236 return 1;
1237 }
1238 data->obj = NULL;
1239 len = -1;
1240 if (PyBytes_Check(obj)) {
1241 data->buf = PyBytes_AsString(obj);
1242 len = PyBytes_Size(obj);
1243 }
1244 else if (PyByteArray_Check(obj)) {
1245 data->buf = PyByteArray_AsString(obj);
1246 len = PyByteArray_Size(obj);
1247 }
1248 else if (PyUnicode_Check(obj) && PyUnicode_READY(obj) == 0 && PyUnicode_IS_C OMPACT_ASCII(obj)) {
1249 data->buf = PyUnicode_DATA(obj);
1250 len = PyUnicode_GET_LENGTH(obj);
1251 }
1252 else {
1253 obj2 = PyUnicode_FromObject(obj);
1254 if (!obj2) {
1255 PyErr_Format(PyExc_TypeError, "string or unicode text buffer expecte d, not %s",
1256 obj->ob_type->tp_name);
1257 return 0;
1258 }
1259 obj3 = PyUnicode_AsEncodedString(obj2, "idna", NULL);
1260 Py_DECREF(obj2);
1261 if (!obj3) {
1262 PyErr_SetString(PyExc_TypeError, "encoding of hostname failed");
1263 return 0;
1264 }
1265 if (!PyBytes_Check(obj3)) {
1266 Py_DECREF(obj3);
1267 PyErr_SetString(PyExc_TypeError, "encoding of hostname failed to ret urn bytes");
1268 return 0;
1269 }
1270 data->obj = obj3;
1271 data->buf = PyBytes_AS_STRING(obj3);
1272 len = PyBytes_GET_SIZE(obj3);
1273 }
1274 if (strlen(data->buf) != len) {
1275 Py_CLEAR(data->obj);
1276 PyErr_SetString(PyExc_TypeError, "host name must not contain NUL charact er");
1277 return 0;
1278 }
1279 return Py_CLEANUP_SUPPORTED;
1280 }
1213 1281
1214 /* Parse a socket address argument according to the socket object's 1282 /* Parse a socket address argument according to the socket object's
1215 address family. Return 1 if the address was in the proper format, 1283 address family. Return 1 if the address was in the proper format,
1216 0 of not. The address is returned through addr_ret, its length 1284 0 of not. The address is returned through addr_ret, its length
1217 through len_ret. */ 1285 through len_ret. */
1218 1286
1219 static int 1287 static int
1220 getsockaddrarg(PySocketSockObject *s, PyObject *args, 1288 getsockaddrarg(PySocketSockObject *s, PyObject *args,
1221 struct sockaddr *addr_ret, int *len_ret) 1289 struct sockaddr *addr_ret, int *len_ret)
1222 { 1290 {
(...skipping 10 matching lines...) Expand all
1233 /* PEP 383. Not using PyUnicode_FSConverter since we need to 1301 /* PEP 383. Not using PyUnicode_FSConverter since we need to
1234 allow embedded nulls on Linux. */ 1302 allow embedded nulls on Linux. */
1235 if (PyUnicode_Check(args)) { 1303 if (PyUnicode_Check(args)) {
1236 if ((args = PyUnicode_EncodeFSDefault(args)) == NULL) 1304 if ((args = PyUnicode_EncodeFSDefault(args)) == NULL)
1237 return 0; 1305 return 0;
1238 } 1306 }
1239 else 1307 else
1240 Py_INCREF(args); 1308 Py_INCREF(args);
1241 if (!PyArg_Parse(args, "y#", &path, &len)) 1309 if (!PyArg_Parse(args, "y#", &path, &len))
1242 goto unix_out; 1310 goto unix_out;
1311 assert(len >= 0);
1243 1312
1244 addr = (struct sockaddr_un*)addr_ret; 1313 addr = (struct sockaddr_un*)addr_ret;
1245 #ifdef linux 1314 #ifdef linux
1246 if (len > 0 && path[0] == 0) { 1315 if (len > 0 && path[0] == 0) {
1247 /* Linux abstract namespace extension */ 1316 /* Linux abstract namespace extension */
1248 if (len > sizeof addr->sun_path) { 1317 if ((size_t)len > sizeof addr->sun_path) {
1249 PyErr_SetString(PyExc_OSError, 1318 PyErr_SetString(PyExc_OSError,
1250 "AF_UNIX path too long"); 1319 "AF_UNIX path too long");
1251 goto unix_out; 1320 goto unix_out;
1252 } 1321 }
1253 } 1322 }
1254 else 1323 else
1255 #endif /* linux */ 1324 #endif /* linux */
1256 { 1325 {
1257 /* regular NULL-terminated string */ 1326 /* regular NULL-terminated string */
1258 if (len >= sizeof addr->sun_path) { 1327 if ((size_t)len >= sizeof addr->sun_path) {
1259 PyErr_SetString(PyExc_OSError, 1328 PyErr_SetString(PyExc_OSError,
1260 "AF_UNIX path too long"); 1329 "AF_UNIX path too long");
1261 goto unix_out; 1330 goto unix_out;
1262 } 1331 }
1263 addr->sun_path[len] = 0; 1332 addr->sun_path[len] = 0;
1264 } 1333 }
1265 addr->sun_family = s->sock_family; 1334 addr->sun_family = s->sock_family;
1266 memcpy(addr->sun_path, path, len); 1335 memcpy(addr->sun_path, path, len);
1267 *len_ret = len + offsetof(struct sockaddr_un, sun_path); 1336 *len_ret = len + offsetof(struct sockaddr_un, sun_path);
1268 retval = 1; 1337 retval = 1;
(...skipping 28 matching lines...) Expand all
1297 #endif 1366 #endif
1298 1367
1299 #ifdef AF_RDS 1368 #ifdef AF_RDS
1300 case AF_RDS: 1369 case AF_RDS:
1301 /* RDS sockets use sockaddr_in: fall-through */ 1370 /* RDS sockets use sockaddr_in: fall-through */
1302 #endif 1371 #endif
1303 1372
1304 case AF_INET: 1373 case AF_INET:
1305 { 1374 {
1306 struct sockaddr_in* addr; 1375 struct sockaddr_in* addr;
1307 char *host; 1376 struct maybe_idna host = {NULL, NULL};
1308 int port, result; 1377 int port, result;
1309 if (!PyTuple_Check(args)) { 1378 if (!PyTuple_Check(args)) {
1310 PyErr_Format( 1379 PyErr_Format(
1311 PyExc_TypeError, 1380 PyExc_TypeError,
1312 "getsockaddrarg: " 1381 "getsockaddrarg: "
1313 "AF_INET address must be tuple, not %.500s", 1382 "AF_INET address must be tuple, not %.500s",
1314 Py_TYPE(args)->tp_name); 1383 Py_TYPE(args)->tp_name);
1315 return 0; 1384 return 0;
1316 } 1385 }
1317 if (!PyArg_ParseTuple(args, "eti:getsockaddrarg", 1386 if (!PyArg_ParseTuple(args, "O&i:getsockaddrarg",
1318 "idna", &host, &port)) 1387 idna_converter, &host, &port))
1319 return 0; 1388 return 0;
1320 addr=(struct sockaddr_in*)addr_ret; 1389 addr=(struct sockaddr_in*)addr_ret;
1321 result = setipaddr(host, (struct sockaddr *)addr, 1390 result = setipaddr(host.buf, (struct sockaddr *)addr,
1322 sizeof(*addr), AF_INET); 1391 sizeof(*addr), AF_INET);
1323 PyMem_Free(host); 1392 idna_cleanup(&host);
1324 if (result < 0) 1393 if (result < 0)
1325 return 0; 1394 return 0;
1326 if (port < 0 || port > 0xffff) { 1395 if (port < 0 || port > 0xffff) {
1327 PyErr_SetString( 1396 PyErr_SetString(
1328 PyExc_OverflowError, 1397 PyExc_OverflowError,
1329 "getsockaddrarg: port must be 0-65535."); 1398 "getsockaddrarg: port must be 0-65535.");
1330 return 0; 1399 return 0;
1331 } 1400 }
1332 addr->sin_family = AF_INET; 1401 addr->sin_family = AF_INET;
1333 addr->sin_port = htons((short)port); 1402 addr->sin_port = htons((short)port);
1334 *len_ret = sizeof *addr; 1403 *len_ret = sizeof *addr;
1335 return 1; 1404 return 1;
1336 } 1405 }
1337 1406
1338 #ifdef ENABLE_IPV6 1407 #ifdef ENABLE_IPV6
1339 case AF_INET6: 1408 case AF_INET6:
1340 { 1409 {
1341 struct sockaddr_in6* addr; 1410 struct sockaddr_in6* addr;
1342 char *host; 1411 struct maybe_idna host = {NULL, NULL};
1343 int port, result; 1412 int port, result;
1344 unsigned int flowinfo, scope_id; 1413 unsigned int flowinfo, scope_id;
1345 flowinfo = scope_id = 0; 1414 flowinfo = scope_id = 0;
1346 if (!PyTuple_Check(args)) { 1415 if (!PyTuple_Check(args)) {
1347 PyErr_Format( 1416 PyErr_Format(
1348 PyExc_TypeError, 1417 PyExc_TypeError,
1349 "getsockaddrarg: " 1418 "getsockaddrarg: "
1350 "AF_INET6 address must be tuple, not %.500s", 1419 "AF_INET6 address must be tuple, not %.500s",
1351 Py_TYPE(args)->tp_name); 1420 Py_TYPE(args)->tp_name);
1352 return 0; 1421 return 0;
1353 } 1422 }
1354 if (!PyArg_ParseTuple(args, "eti|II", 1423 if (!PyArg_ParseTuple(args, "O&i|II",
1355 "idna", &host, &port, &flowinfo, 1424 idna_converter, &host, &port, &flowinfo,
1356 &scope_id)) { 1425 &scope_id)) {
1357 return 0; 1426 return 0;
1358 } 1427 }
1359 addr = (struct sockaddr_in6*)addr_ret; 1428 addr = (struct sockaddr_in6*)addr_ret;
1360 result = setipaddr(host, (struct sockaddr *)addr, 1429 result = setipaddr(host.buf, (struct sockaddr *)addr,
1361 sizeof(*addr), AF_INET6); 1430 sizeof(*addr), AF_INET6);
1362 PyMem_Free(host); 1431 idna_cleanup(&host);
1363 if (result < 0) 1432 if (result < 0)
1364 return 0; 1433 return 0;
1365 if (port < 0 || port > 0xffff) { 1434 if (port < 0 || port > 0xffff) {
1366 PyErr_SetString( 1435 PyErr_SetString(
1367 PyExc_OverflowError, 1436 PyExc_OverflowError,
1368 "getsockaddrarg: port must be 0-65535."); 1437 "getsockaddrarg: port must be 0-65535.");
1369 return 0; 1438 return 0;
1370 } 1439 }
1371 if (flowinfo > 0xfffff) { 1440 if (flowinfo > 0xfffff) {
1372 PyErr_SetString( 1441 PyErr_SetString(
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
1600 addr = (struct sockaddr_can *)addr_ret; 1669 addr = (struct sockaddr_can *)addr_ret;
1601 1670
1602 if (!PyArg_ParseTuple(args, "O&", PyUnicode_FSConverter, 1671 if (!PyArg_ParseTuple(args, "O&", PyUnicode_FSConverter,
1603 &interfaceName)) 1672 &interfaceName))
1604 return 0; 1673 return 0;
1605 1674
1606 len = PyBytes_GET_SIZE(interfaceName); 1675 len = PyBytes_GET_SIZE(interfaceName);
1607 1676
1608 if (len == 0) { 1677 if (len == 0) {
1609 ifr.ifr_ifindex = 0; 1678 ifr.ifr_ifindex = 0;
1610 } else if (len < sizeof(ifr.ifr_name)) { 1679 } else if ((size_t)len < sizeof(ifr.ifr_name)) {
1611 strncpy(ifr.ifr_name, PyBytes_AS_STRING(interfaceName), sizeof(i fr.ifr_name)); 1680 strncpy(ifr.ifr_name, PyBytes_AS_STRING(interfaceName), sizeof(i fr.ifr_name));
1612 ifr.ifr_name[(sizeof(ifr.ifr_name))-1] = '\0'; 1681 ifr.ifr_name[(sizeof(ifr.ifr_name))-1] = '\0';
1613 if (ioctl(s->sock_fd, SIOCGIFINDEX, &ifr) < 0) { 1682 if (ioctl(s->sock_fd, SIOCGIFINDEX, &ifr) < 0) {
1614 s->errorhandler(); 1683 s->errorhandler();
1615 Py_DECREF(interfaceName); 1684 Py_DECREF(interfaceName);
1616 return 0; 1685 return 0;
1617 } 1686 }
1618 } else { 1687 } else {
1619 PyErr_SetString(PyExc_OSError, 1688 PyErr_SetString(PyExc_OSError,
1620 "AF_CAN interface name too long"); 1689 "AF_CAN interface name too long");
(...skipping 2238 matching lines...) Expand 10 before | Expand all | Expand 10 after
3859 (void) SOCKETCLOSE(s->sock_fd); 3928 (void) SOCKETCLOSE(s->sock_fd);
3860 Py_REFCNT(s) = old_refcount; 3929 Py_REFCNT(s) = old_refcount;
3861 } 3930 }
3862 Py_TYPE(s)->tp_free((PyObject *)s); 3931 Py_TYPE(s)->tp_free((PyObject *)s);
3863 } 3932 }
3864 3933
3865 3934
3866 static PyObject * 3935 static PyObject *
3867 sock_repr(PySocketSockObject *s) 3936 sock_repr(PySocketSockObject *s)
3868 { 3937 {
3938 long sock_fd;
3939 /* On Windows, this test is needed because SOCKET_T is unsigned */
3940 if (s->sock_fd == INVALID_SOCKET) {
3941 sock_fd = -1;
3942 }
3869 #if SIZEOF_SOCKET_T > SIZEOF_LONG 3943 #if SIZEOF_SOCKET_T > SIZEOF_LONG
3870 if (s->sock_fd > LONG_MAX) { 3944 else if (s->sock_fd > LONG_MAX) {
3871 /* this can occur on Win64, and actually there is a special 3945 /* this can occur on Win64, and actually there is a special
3872 ugly printf formatter for decimal pointer length integer 3946 ugly printf formatter for decimal pointer length integer
3873 printing, only bother if necessary*/ 3947 printing, only bother if necessary*/
3874 PyErr_SetString(PyExc_OverflowError, 3948 PyErr_SetString(PyExc_OverflowError,
3875 "no printf formatter to display " 3949 "no printf formatter to display "
3876 "the socket descriptor in decimal"); 3950 "the socket descriptor in decimal");
3877 return NULL; 3951 return NULL;
3878 } 3952 }
3879 #endif 3953 #endif
3954 else
3955 sock_fd = (long)s->sock_fd;
3880 return PyUnicode_FromFormat( 3956 return PyUnicode_FromFormat(
3881 "<socket object, fd=%ld, family=%d, type=%d, proto=%d>", 3957 "<socket object, fd=%ld, family=%d, type=%d, proto=%d>",
3882 (long)s->sock_fd, s->sock_family, 3958 sock_fd, s->sock_family,
3883 s->sock_type, 3959 s->sock_type,
3884 s->sock_proto); 3960 s->sock_proto);
3885 } 3961 }
3886 3962
3887 3963
3888 /* Create a new, uninitialized socket object. */ 3964 /* Create a new, uninitialized socket object. */
3889 3965
3890 static PyObject * 3966 static PyObject *
3891 sock_new(PyTypeObject *type, PyObject *args, PyObject *kwds) 3967 sock_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
3892 { 3968 {
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
4208 4284
4209 PyDoc_STRVAR(gethostbyname_doc, 4285 PyDoc_STRVAR(gethostbyname_doc,
4210 "gethostbyname(host) -> address\n\ 4286 "gethostbyname(host) -> address\n\
4211 \n\ 4287 \n\
4212 Return the IP address (a string of the form '255.255.255.255') for a host."); 4288 Return the IP address (a string of the form '255.255.255.255') for a host.");
4213 4289
4214 4290
4215 /* Convenience function common to gethostbyname_ex and gethostbyaddr */ 4291 /* Convenience function common to gethostbyname_ex and gethostbyaddr */
4216 4292
4217 static PyObject * 4293 static PyObject *
4218 gethost_common(struct hostent *h, struct sockaddr *addr, int alen, int af) 4294 gethost_common(struct hostent *h, struct sockaddr *addr, size_t alen, int af)
4219 { 4295 {
4220 char **pch; 4296 char **pch;
4221 PyObject *rtn_tuple = (PyObject *)NULL; 4297 PyObject *rtn_tuple = (PyObject *)NULL;
4222 PyObject *name_list = (PyObject *)NULL; 4298 PyObject *name_list = (PyObject *)NULL;
4223 PyObject *addr_list = (PyObject *)NULL; 4299 PyObject *addr_list = (PyObject *)NULL;
4224 PyObject *tmp; 4300 PyObject *tmp;
4225 4301
4226 if (h == NULL) { 4302 if (h == NULL) {
4227 /* Let's get real error message to return */ 4303 /* Let's get real error message to return */
4228 set_herror(h_errno); 4304 set_herror(h_errno);
(...skipping 2699 matching lines...) Expand 10 before | Expand all | Expand 10 after
6928 return NULL; 7004 return NULL;
6929 memcpy(&packed_addr, src, sizeof(packed_addr)); 7005 memcpy(&packed_addr, src, sizeof(packed_addr));
6930 return strncpy(dst, inet_ntoa(packed_addr), size); 7006 return strncpy(dst, inet_ntoa(packed_addr), size);
6931 } 7007 }
6932 /* Should set errno to EAFNOSUPPORT */ 7008 /* Should set errno to EAFNOSUPPORT */
6933 return NULL; 7009 return NULL;
6934 } 7010 }
6935 7011
6936 #endif 7012 #endif
6937 #endif 7013 #endif
LEFTRIGHT

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7