Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
19467d27
Commit
19467d27
authored
Aug 17, 2010
by
Antoine Pitrou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean some 64-bit issues. Also, always spell "ssize_t" "Py_ssize_t".
parent
3fccfcb7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
30 deletions
+33
-30
Modules/socketmodule.c
Modules/socketmodule.c
+33
-30
No files found.
Modules/socketmodule.c
View file @
19467d27
...
@@ -678,9 +678,11 @@ internal_select(PySocketSockObject *s, int writing)
...
@@ -678,9 +678,11 @@ internal_select(PySocketSockObject *s, int writing)
/* See if the socket is ready */
/* See if the socket is ready */
if
(
writing
)
if
(
writing
)
n
=
select
(
s
->
sock_fd
+
1
,
NULL
,
&
fds
,
NULL
,
&
tv
);
n
=
select
(
Py_SAFE_DOWNCAST
(
s
->
sock_fd
+
1
,
SOCKET_T
,
int
),
NULL
,
&
fds
,
NULL
,
&
tv
);
else
else
n
=
select
(
s
->
sock_fd
+
1
,
&
fds
,
NULL
,
NULL
,
&
tv
);
n
=
select
(
Py_SAFE_DOWNCAST
(
s
->
sock_fd
+
1
,
SOCKET_T
,
int
),
&
fds
,
NULL
,
NULL
,
&
tv
);
}
}
#endif
#endif
...
@@ -937,7 +939,7 @@ makebdaddr(bdaddr_t *bdaddr)
...
@@ -937,7 +939,7 @@ makebdaddr(bdaddr_t *bdaddr)
/*ARGSUSED*/
/*ARGSUSED*/
static
PyObject
*
static
PyObject
*
makesockaddr
(
int
sockfd
,
struct
sockaddr
*
addr
,
in
t
addrlen
,
int
proto
)
makesockaddr
(
SOCKET_T
sockfd
,
struct
sockaddr
*
addr
,
size_
t
addrlen
,
int
proto
)
{
{
if
(
addrlen
==
0
)
{
if
(
addrlen
==
0
)
{
/* No address -- may be recvfrom() from known socket */
/* No address -- may be recvfrom() from known socket */
...
@@ -1908,7 +1910,8 @@ internal_connect(PySocketSockObject *s, struct sockaddr *addr, int addrlen,
...
@@ -1908,7 +1910,8 @@ internal_connect(PySocketSockObject *s, struct sockaddr *addr, int addrlen,
FD_SET
(
s
->
sock_fd
,
&
fds
);
FD_SET
(
s
->
sock_fd
,
&
fds
);
FD_ZERO
(
&
fds_exc
);
FD_ZERO
(
&
fds_exc
);
FD_SET
(
s
->
sock_fd
,
&
fds_exc
);
FD_SET
(
s
->
sock_fd
,
&
fds_exc
);
res
=
select
(
s
->
sock_fd
+
1
,
NULL
,
&
fds
,
&
fds_exc
,
&
tv
);
res
=
select
(
Py_SAFE_DOWNCAST
(
s
->
sock_fd
+
1
,
SOCKET_T
,
int
),
NULL
,
&
fds
,
&
fds_exc
,
&
tv
);
if
(
res
==
0
)
{
if
(
res
==
0
)
{
res
=
WSAEWOULDBLOCK
;
res
=
WSAEWOULDBLOCK
;
timeout
=
1
;
timeout
=
1
;
...
@@ -2151,10 +2154,10 @@ will allow before refusing new connections.");
...
@@ -2151,10 +2154,10 @@ will allow before refusing new connections.");
* also possible that we return a number of bytes smaller than the request
* also possible that we return a number of bytes smaller than the request
* bytes.
* bytes.
*/
*/
static
ssize_t
static
Py_
ssize_t
sock_recv_guts
(
PySocketSockObject
*
s
,
char
*
cbuf
,
in
t
len
,
int
flags
)
sock_recv_guts
(
PySocketSockObject
*
s
,
char
*
cbuf
,
Py_ssize_
t
len
,
int
flags
)
{
{
ssize_t
outlen
=
-
1
;
Py_
ssize_t
outlen
=
-
1
;
int
timeout
;
int
timeout
;
#ifdef __VMS
#ifdef __VMS
int
remaining
;
int
remaining
;
...
@@ -2236,11 +2239,11 @@ sock_recv_guts(PySocketSockObject *s, char* cbuf, int len, int flags)
...
@@ -2236,11 +2239,11 @@ sock_recv_guts(PySocketSockObject *s, char* cbuf, int len, int flags)
static
PyObject
*
static
PyObject
*
sock_recv
(
PySocketSockObject
*
s
,
PyObject
*
args
)
sock_recv
(
PySocketSockObject
*
s
,
PyObject
*
args
)
{
{
int
recvlen
,
flags
=
0
;
Py_ssize_t
recvlen
,
outlen
;
ssize_t
outlen
;
int
flags
=
0
;
PyObject
*
buf
;
PyObject
*
buf
;
if
(
!
PyArg_ParseTuple
(
args
,
"
i
|i:recv"
,
&
recvlen
,
&
flags
))
if
(
!
PyArg_ParseTuple
(
args
,
"
n
|i:recv"
,
&
recvlen
,
&
flags
))
return
NULL
;
return
NULL
;
if
(
recvlen
<
0
)
{
if
(
recvlen
<
0
)
{
...
@@ -2287,14 +2290,13 @@ sock_recv_into(PySocketSockObject *s, PyObject *args, PyObject *kwds)
...
@@ -2287,14 +2290,13 @@ sock_recv_into(PySocketSockObject *s, PyObject *args, PyObject *kwds)
{
{
static
char
*
kwlist
[]
=
{
"buffer"
,
"nbytes"
,
"flags"
,
0
};
static
char
*
kwlist
[]
=
{
"buffer"
,
"nbytes"
,
"flags"
,
0
};
int
recvlen
=
0
,
flags
=
0
;
int
flags
=
0
;
ssize_t
readlen
;
Py_buffer
pbuf
;
Py_buffer
pbuf
;
char
*
buf
;
char
*
buf
;
int
buflen
;
Py_ssize_t
buflen
,
readlen
,
recvlen
=
0
;
/* Get the buffer's memory */
/* Get the buffer's memory */
if
(
!
PyArg_ParseTupleAndKeywords
(
args
,
kwds
,
"w*|
i
i:recv_into"
,
kwlist
,
if
(
!
PyArg_ParseTupleAndKeywords
(
args
,
kwds
,
"w*|
n
i:recv_into"
,
kwlist
,
&
pbuf
,
&
recvlen
,
&
flags
))
&
pbuf
,
&
recvlen
,
&
flags
))
return
NULL
;
return
NULL
;
buf
=
pbuf
.
buf
;
buf
=
pbuf
.
buf
;
...
@@ -2354,13 +2356,13 @@ See recv() for documentation about the flags.");
...
@@ -2354,13 +2356,13 @@ See recv() for documentation about the flags.");
* 'addr' is a return value for the address object. Note that you must decref
* 'addr' is a return value for the address object. Note that you must decref
* it yourself.
* it yourself.
*/
*/
static
ssize_t
static
Py_
ssize_t
sock_recvfrom_guts
(
PySocketSockObject
*
s
,
char
*
cbuf
,
in
t
len
,
int
flags
,
sock_recvfrom_guts
(
PySocketSockObject
*
s
,
char
*
cbuf
,
Py_ssize_
t
len
,
int
flags
,
PyObject
**
addr
)
PyObject
**
addr
)
{
{
sock_addr_t
addrbuf
;
sock_addr_t
addrbuf
;
int
timeout
;
int
timeout
;
ssize_t
n
=
-
1
;
Py_
ssize_t
n
=
-
1
;
socklen_t
addrlen
;
socklen_t
addrlen
;
*
addr
=
NULL
;
*
addr
=
NULL
;
...
@@ -2416,10 +2418,10 @@ sock_recvfrom(PySocketSockObject *s, PyObject *args)
...
@@ -2416,10 +2418,10 @@ sock_recvfrom(PySocketSockObject *s, PyObject *args)
PyObject
*
buf
=
NULL
;
PyObject
*
buf
=
NULL
;
PyObject
*
addr
=
NULL
;
PyObject
*
addr
=
NULL
;
PyObject
*
ret
=
NULL
;
PyObject
*
ret
=
NULL
;
int
recvlen
,
flags
=
0
;
int
flags
=
0
;
ssize_t
outlen
;
Py_ssize_t
recvlen
,
outlen
;
if
(
!
PyArg_ParseTuple
(
args
,
"
i
|i:recvfrom"
,
&
recvlen
,
&
flags
))
if
(
!
PyArg_ParseTuple
(
args
,
"
n
|i:recvfrom"
,
&
recvlen
,
&
flags
))
return
NULL
;
return
NULL
;
if
(
recvlen
<
0
)
{
if
(
recvlen
<
0
)
{
...
@@ -2467,15 +2469,14 @@ sock_recvfrom_into(PySocketSockObject *s, PyObject *args, PyObject* kwds)
...
@@ -2467,15 +2469,14 @@ sock_recvfrom_into(PySocketSockObject *s, PyObject *args, PyObject* kwds)
{
{
static
char
*
kwlist
[]
=
{
"buffer"
,
"nbytes"
,
"flags"
,
0
};
static
char
*
kwlist
[]
=
{
"buffer"
,
"nbytes"
,
"flags"
,
0
};
int
recvlen
=
0
,
flags
=
0
;
int
flags
=
0
;
ssize_t
readlen
;
Py_buffer
pbuf
;
Py_buffer
pbuf
;
char
*
buf
;
char
*
buf
;
int
buflen
;
Py_ssize_t
readlen
,
buflen
,
recvlen
=
0
;
PyObject
*
addr
=
NULL
;
PyObject
*
addr
=
NULL
;
if
(
!
PyArg_ParseTupleAndKeywords
(
args
,
kwds
,
"w*|
i
i:recvfrom_into"
,
if
(
!
PyArg_ParseTupleAndKeywords
(
args
,
kwds
,
"w*|
n
i:recvfrom_into"
,
kwlist
,
&
pbuf
,
kwlist
,
&
pbuf
,
&
recvlen
,
&
flags
))
&
recvlen
,
&
flags
))
return
NULL
;
return
NULL
;
...
@@ -2505,7 +2506,7 @@ sock_recvfrom_into(PySocketSockObject *s, PyObject *args, PyObject* kwds)
...
@@ -2505,7 +2506,7 @@ sock_recvfrom_into(PySocketSockObject *s, PyObject *args, PyObject* kwds)
PyBuffer_Release
(
&
pbuf
);
PyBuffer_Release
(
&
pbuf
);
/* Return the number of bytes read and the address. Note that we do
/* Return the number of bytes read and the address. Note that we do
not do anything special here in the case that readlen < recvlen. */
not do anything special here in the case that readlen < recvlen. */
return
Py_BuildValue
(
"
l
N"
,
readlen
,
addr
);
return
Py_BuildValue
(
"
n
N"
,
readlen
,
addr
);
}
}
PyDoc_STRVAR
(
recvfrom_into_doc
,
PyDoc_STRVAR
(
recvfrom_into_doc
,
...
@@ -2520,7 +2521,8 @@ static PyObject *
...
@@ -2520,7 +2521,8 @@ static PyObject *
sock_send
(
PySocketSockObject
*
s
,
PyObject
*
args
)
sock_send
(
PySocketSockObject
*
s
,
PyObject
*
args
)
{
{
char
*
buf
;
char
*
buf
;
int
len
,
n
=
-
1
,
flags
=
0
,
timeout
;
Py_ssize_t
len
,
n
=
-
1
;
int
flags
=
0
,
timeout
;
Py_buffer
pbuf
;
Py_buffer
pbuf
;
if
(
!
PyArg_ParseTuple
(
args
,
"y*|i:send"
,
&
pbuf
,
&
flags
))
if
(
!
PyArg_ParseTuple
(
args
,
"y*|i:send"
,
&
pbuf
,
&
flags
))
...
@@ -2551,7 +2553,7 @@ sock_send(PySocketSockObject *s, PyObject *args)
...
@@ -2551,7 +2553,7 @@ sock_send(PySocketSockObject *s, PyObject *args)
}
}
if
(
n
<
0
)
if
(
n
<
0
)
return
s
->
errorhandler
();
return
s
->
errorhandler
();
return
PyLong_From
Long
((
long
)
n
);
return
PyLong_From
Ssize_t
(
n
);
}
}
PyDoc_STRVAR
(
send_doc
,
PyDoc_STRVAR
(
send_doc
,
...
@@ -2568,7 +2570,8 @@ static PyObject *
...
@@ -2568,7 +2570,8 @@ static PyObject *
sock_sendall
(
PySocketSockObject
*
s
,
PyObject
*
args
)
sock_sendall
(
PySocketSockObject
*
s
,
PyObject
*
args
)
{
{
char
*
buf
;
char
*
buf
;
int
len
,
n
=
-
1
,
flags
=
0
,
timeout
;
Py_ssize_t
len
,
n
=
-
1
;
int
flags
=
0
,
timeout
;
Py_buffer
pbuf
;
Py_buffer
pbuf
;
if
(
!
PyArg_ParseTuple
(
args
,
"y*|i:sendall"
,
&
pbuf
,
&
flags
))
if
(
!
PyArg_ParseTuple
(
args
,
"y*|i:sendall"
,
&
pbuf
,
&
flags
))
...
@@ -2678,7 +2681,7 @@ sock_sendto(PySocketSockObject *s, PyObject *args)
...
@@ -2678,7 +2681,7 @@ sock_sendto(PySocketSockObject *s, PyObject *args)
}
}
if
(
n
<
0
)
if
(
n
<
0
)
return
s
->
errorhandler
();
return
s
->
errorhandler
();
return
PyLong_From
Long
((
long
)
n
);
return
PyLong_From
Ssize_t
(
n
);
}
}
PyDoc_STRVAR
(
sendto_doc
,
PyDoc_STRVAR
(
sendto_doc
,
...
@@ -3993,7 +3996,7 @@ socket_getnameinfo(PyObject *self, PyObject *args)
...
@@ -3993,7 +3996,7 @@ socket_getnameinfo(PyObject *self, PyObject *args)
}
}
#endif
#endif
}
}
error
=
getnameinfo
(
res
->
ai_addr
,
res
->
ai_addrlen
,
error
=
getnameinfo
(
res
->
ai_addr
,
(
socklen_t
)
res
->
ai_addrlen
,
hbuf
,
sizeof
(
hbuf
),
pbuf
,
sizeof
(
pbuf
),
flags
);
hbuf
,
sizeof
(
hbuf
),
pbuf
,
sizeof
(
pbuf
),
flags
);
if
(
error
)
{
if
(
error
)
{
set_gaierror
(
error
);
set_gaierror
(
error
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment