[CalendarServer-changes] [10943] CalendarServer/trunk/twext/python/sendfd.py
source_changes at macosforge.org
source_changes at macosforge.org
Mon Mar 18 12:53:52 PDT 2013
Revision: 10943
http://trac.calendarserver.org//changeset/10943
Author: wsanchez at apple.com
Date: 2013-03-18 12:53:51 -0700 (Mon, 18 Mar 2013)
Log Message:
-----------
Deal with teeny int and not-so-teeny FD.
Fixes: #801
Fixed by: Axel.Rau at Chaos1.DE
Modified Paths:
--------------
CalendarServer/trunk/twext/python/sendfd.py
Modified: CalendarServer/trunk/twext/python/sendfd.py
===================================================================
--- CalendarServer/trunk/twext/python/sendfd.py 2013-03-18 19:43:40 UTC (rev 10942)
+++ CalendarServer/trunk/twext/python/sendfd.py 2013-03-18 19:53:51 UTC (rev 10943)
@@ -15,7 +15,7 @@
# limitations under the License.
##
-from struct import pack, unpack
+from struct import pack, unpack, calcsize
from socket import SOL_SOCKET
from twext.python.sendmsg import sendmsg, recvmsg, SCM_RIGHTS
@@ -62,5 +62,10 @@
# cmsg_level and cmsg_type really need to be SOL_SOCKET / SCM_RIGHTS, but
# since those are the *only* standard values, there's not much point in
# checking.
- [unpackedFD] = unpack("i", packedFD)
+ unpackedFD = 0
+ int_size = calcsize("i")
+ if len(packedFD) > int_size: # [ar]happens on 64 bit architecture (FreeBSD)
+ [unpackedFD] = unpack("i", packedFD[0:int_size])
+ else:
+ [unpackedFD] = unpack("i", packedFD)
return (unpackedFD, data)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130318/51f9d532/attachment.html>
More information about the calendarserver-changes
mailing list