mirror of
https://github.com/php/php-src.git
synced 2024-11-25 02:44:58 +08:00
Misc sendto/recvfrom tweaks that have been pending here for a while...
This commit is contained in:
parent
05a3fabacb
commit
ae7285d658
@ -385,6 +385,7 @@ PHPAPI int php_stream_xport_recvfrom(php_stream *stream, char *buf, size_t bufle
|
||||
php_stream_xport_param param;
|
||||
int ret = 0;
|
||||
int recvd_len = 0;
|
||||
#if 0
|
||||
int oob;
|
||||
|
||||
if (flags == 0 && addr == NULL) {
|
||||
@ -416,6 +417,7 @@ PHPAPI int php_stream_xport_recvfrom(php_stream *stream, char *buf, size_t bufle
|
||||
return recvd_len;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* otherwise, we are going to bypass the buffer */
|
||||
|
||||
@ -453,9 +455,11 @@ PHPAPI int php_stream_xport_sendto(php_stream *stream, const char *buf, size_t b
|
||||
int ret = 0;
|
||||
int oob;
|
||||
|
||||
#if 0
|
||||
if (flags == 0 && addr == NULL) {
|
||||
return php_stream_write(stream, buf, buflen);
|
||||
}
|
||||
#endif
|
||||
|
||||
oob = (flags & STREAM_OOB) == STREAM_OOB;
|
||||
|
||||
|
@ -185,8 +185,11 @@ static int php_sockop_close(php_stream *stream, int close_handle TSRMLS_DC)
|
||||
|
||||
static int php_sockop_flush(php_stream *stream TSRMLS_DC)
|
||||
{
|
||||
#if 0
|
||||
php_netstream_data_t *sock = (php_netstream_data_t*)stream->abstract;
|
||||
return fsync(sock->socket);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int php_sockop_stat(php_stream *stream, php_stream_statbuf *ssb TSRMLS_DC)
|
||||
@ -195,6 +198,16 @@ static int php_sockop_stat(php_stream *stream, php_stream_statbuf *ssb TSRMLS_DC
|
||||
return fstat(sock->socket, &ssb->sb);
|
||||
}
|
||||
|
||||
static inline int sock_sendto(php_netstream_data_t *sock, char *buf, size_t buflen, int flags,
|
||||
struct sockaddr *addr, socklen_t addrlen
|
||||
TSRMLS_DC)
|
||||
{
|
||||
if (addr) {
|
||||
return sendto(sock->socket, buf, buflen, flags, addr, addrlen);
|
||||
}
|
||||
return send(sock->socket, buf, buflen, flags);
|
||||
}
|
||||
|
||||
static inline int sock_recvfrom(php_netstream_data_t *sock, char *buf, size_t buflen, int flags,
|
||||
char **textaddr, long *textaddrlen,
|
||||
struct sockaddr **addr, socklen_t *addrlen
|
||||
@ -314,7 +327,7 @@ static int php_sockop_set_option(php_stream *stream, int option, int value, void
|
||||
if ((xparam->inputs.flags & STREAM_OOB) == STREAM_OOB) {
|
||||
flags |= MSG_OOB;
|
||||
}
|
||||
xparam->outputs.returncode = sendto(sock->socket,
|
||||
xparam->outputs.returncode = sock_sendto(sock,
|
||||
xparam->inputs.buf, xparam->inputs.buflen,
|
||||
flags,
|
||||
xparam->inputs.addr,
|
||||
|
Loading…
Reference in New Issue
Block a user