This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
| Author | niallo |
|---|---|
| Recipients | niallo |
| Date | 2008年07月16日.01:38:50 |
| SpamBayes Score | 0.010541628 |
| Marked as misclassified | No |
| Message-id | <1216172332.9.0.582364259682.issue3372@psf.upfronthosting.co.za> |
| In-reply-to |
| Content | |
|---|---|
socket.setsockopt() sets an optlen of '4' in the setsockopt system call for options IP_MULTICAST_TTL and IP_MULTICAST_LOOP. On OpenBSD, this causes the kernel to hit an error condition and set errno 22 when these options are set: socket.error: (22, 'Invalid argument') Yielded by e.g. socket.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, 1) According to both FreeBSD and OpenBSD manual pages (see e.g. http://www.freebsd.org/cgi/man.cgi?query=ip&apropos=0&sektion=0&manpath=FreeBSD+7.0-RELEASE&format=html), these fields are in fact both 8 bit unsigned, and the manuals suggest the following: u_char ttl; /* range: 0 to 255, default = 1 */ setsockopt(s, IPPROTO_IP, IP_MULTICAST_TTL, &ttl, sizeof(ttl)); While '4' (sizeof int) is correct for many options, special casing is needed in Modules/socketmodule.c. The following diff fixes the issue for me on OpenBSD: @@ -1716,12 +1719,8 @@ sock_setsockopt(PySocketSockObject *s, PyObject *args) if (PyArg_ParseTuple(args, "iii:setsockopt", &level, &optname, &flag)) { - buflen = sizeof flag; - /* Multi cast options take shorter arguments */ - if (optname == IP_MULTICAST_TTL - || optname == IP_MULTICAST_LOOP) - buflen = sizeof(u_char); buf = (char *) &flag; + buflen = sizeof flag; } else { PyErr_Clear(); |
|
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2008年07月16日 01:38:53 | niallo | set | spambayes_score: 0.0105416 -> 0.010541628 recipients: + niallo |
| 2008年07月16日 01:38:52 | niallo | set | spambayes_score: 0.0105416 -> 0.0105416 messageid: <1216172332.9.0.582364259682.issue3372@psf.upfronthosting.co.za> |
| 2008年07月16日 01:38:52 | niallo | link | issue3372 messages |
| 2008年07月16日 01:38:51 | niallo | create | |