NBD client: nodelay
This commit is contained in:
parent
4becb93787
commit
95db008a68
2 changed files with 19 additions and 0 deletions
17
utils.cpp
17
utils.cpp
|
@ -6,7 +6,11 @@
|
||||||
#if defined(ESP32) || defined(BUILD_FOR_RP2040)
|
#if defined(ESP32) || defined(BUILD_FOR_RP2040)
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include "rp2040.h"
|
#include "rp2040.h"
|
||||||
|
#else
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <netinet/tcp.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <sys/socket.h>
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
@ -23,6 +27,8 @@
|
||||||
#include "win32.h"
|
#include "win32.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "log.h"
|
||||||
|
|
||||||
|
|
||||||
void setBit(uint16_t & v, const int bit, const bool vb)
|
void setBit(uint16_t & v, const int bit, const bool vb)
|
||||||
{
|
{
|
||||||
|
@ -236,3 +242,14 @@ void update_word(uint16_t *const w, const bool msb, const uint8_t v)
|
||||||
(*w) |= v;
|
(*w) |= v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void set_nodelay(const int fd)
|
||||||
|
{
|
||||||
|
int flags = 1;
|
||||||
|
#if defined(__FreeBSD__) || defined(ESP32)
|
||||||
|
if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (void *)&flags, sizeof(flags)) == -1)
|
||||||
|
#else
|
||||||
|
if (setsockopt(fd, SOL_TCP, TCP_NODELAY, (void *)&flags, sizeof(flags)) == -1)
|
||||||
|
#endif
|
||||||
|
DOLOG(warning, true, "Cannot disable nagle algorithm");
|
||||||
|
}
|
||||||
|
|
2
utils.h
2
utils.h
|
@ -25,3 +25,5 @@ ssize_t WRITE(int fd, const char *whereto, size_t len);
|
||||||
ssize_t READ(int fd, char *whereto, size_t len);
|
ssize_t READ(int fd, char *whereto, size_t len);
|
||||||
|
|
||||||
void update_word(uint16_t *const w, const bool msb, const uint8_t v);
|
void update_word(uint16_t *const w, const bool msb, const uint8_t v);
|
||||||
|
|
||||||
|
void set_nodelay(const int fd);
|
||||||
|
|
Loading…
Add table
Reference in a new issue