mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-01-18 02:40:13 +00:00
.
This commit is contained in:
parent
a35fa7ac93
commit
cd3d77987c
@ -68,7 +68,7 @@ struct HttpPhyHandler
|
|||||||
inline void phyOnTcpConnect(PhySocket *sock,void **uptr,bool success)
|
inline void phyOnTcpConnect(PhySocket *sock,void **uptr,bool success)
|
||||||
{
|
{
|
||||||
if (success) {
|
if (success) {
|
||||||
phy->tcpSetNotifyWritable(sock,true);
|
phy->setNotifyWritable(sock,true);
|
||||||
} else {
|
} else {
|
||||||
*responseBody = "connection failed";
|
*responseBody = "connection failed";
|
||||||
error = true;
|
error = true;
|
||||||
@ -92,12 +92,12 @@ struct HttpPhyHandler
|
|||||||
inline void phyOnTcpWritable(PhySocket *sock,void **uptr)
|
inline void phyOnTcpWritable(PhySocket *sock,void **uptr)
|
||||||
{
|
{
|
||||||
if (writePtr < writeSize) {
|
if (writePtr < writeSize) {
|
||||||
long n = phy->tcpSend(sock,writeBuf + writePtr,writeSize - writePtr,true);
|
long n = phy->streamSend(sock,writeBuf + writePtr,writeSize - writePtr,true);
|
||||||
if (n > 0)
|
if (n > 0)
|
||||||
writePtr += n;
|
writePtr += n;
|
||||||
}
|
}
|
||||||
if (writePtr >= writeSize)
|
if (writePtr >= writeSize)
|
||||||
phy->tcpSetNotifyWritable(sock,false);
|
phy->setNotifyWritable(sock,false);
|
||||||
}
|
}
|
||||||
|
|
||||||
http_parser parser;
|
http_parser parser;
|
||||||
|
@ -665,19 +665,21 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempt to send data to a TCP connection (non-blocking)
|
* Attempt to send data to a stream socket (non-blocking)
|
||||||
*
|
*
|
||||||
* If -1 is returned, the socket should no longer be used as it is now
|
* If -1 is returned, the socket should no longer be used as it is now
|
||||||
* destroyed. If callCloseHandler is true, the close handler will be
|
* destroyed. If callCloseHandler is true, the close handler will be
|
||||||
* called before the function returns.
|
* called before the function returns.
|
||||||
*
|
*
|
||||||
* @param sock An open TCP socket (other socket types will fail)
|
* This can be used with TCP, Unix, or socket pair sockets.
|
||||||
|
*
|
||||||
|
* @param sock An open stream socket (other socket types will fail)
|
||||||
* @param data Data to send
|
* @param data Data to send
|
||||||
* @param len Length of data
|
* @param len Length of data
|
||||||
* @param callCloseHandler If true, call close handler on socket closing failure condition (default: true)
|
* @param callCloseHandler If true, call close handler on socket closing failure condition (default: true)
|
||||||
* @return Number of bytes actually sent or -1 on fatal error (socket closure)
|
* @return Number of bytes actually sent or -1 on fatal error (socket closure)
|
||||||
*/
|
*/
|
||||||
inline long tcpSend(PhySocket *sock,const void *data,unsigned long len,bool callCloseHandler = true)
|
inline long streamSend(PhySocket *sock,const void *data,unsigned long len,bool callCloseHandler = true)
|
||||||
{
|
{
|
||||||
PhySocketImpl &sws = *(reinterpret_cast<PhySocketImpl *>(sock));
|
PhySocketImpl &sws = *(reinterpret_cast<PhySocketImpl *>(sock));
|
||||||
#if defined(_WIN32) || defined(_WIN64)
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
@ -755,16 +757,18 @@ public:
|
|||||||
#endif // __UNIX_LIKE__
|
#endif // __UNIX_LIKE__
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set whether we want to be notified via the TCP writability handler when a socket is writable
|
* For streams, sets whether we want to be notified that the socket is writable
|
||||||
|
*
|
||||||
|
* This can be used with TCP, Unix, or socket pair sockets.
|
||||||
*
|
*
|
||||||
* Call whack() if this is being done from another thread and you want
|
* Call whack() if this is being done from another thread and you want
|
||||||
* it to take effect immediately. Otherwise it is only guaranteed to
|
* it to take effect immediately. Otherwise it is only guaranteed to
|
||||||
* take effect on the next poll().
|
* take effect on the next poll().
|
||||||
*
|
*
|
||||||
* @param sock TCP connection socket (other types are not valid)
|
* @param sock Stream connection socket
|
||||||
* @param notifyWritable Want writable notifications?
|
* @param notifyWritable Want writable notifications?
|
||||||
*/
|
*/
|
||||||
inline const void tcpSetNotifyWritable(PhySocket *sock,bool notifyWritable)
|
inline const void setNotifyWritable(PhySocket *sock,bool notifyWritable)
|
||||||
{
|
{
|
||||||
PhySocketImpl &sws = *(reinterpret_cast<PhySocketImpl *>(sock));
|
PhySocketImpl &sws = *(reinterpret_cast<PhySocketImpl *>(sock));
|
||||||
if (notifyWritable) {
|
if (notifyWritable) {
|
||||||
|
Loading…
Reference in New Issue
Block a user