remove some system include files
This commit is contained in:
parent
8ccd079f6e
commit
1f3b7197b1
|
@ -24,10 +24,8 @@ extern "C" {
|
|||
|
||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
||||
typedef int32_t FileFd;
|
||||
typedef SOCKET SocketFd;
|
||||
#else
|
||||
typedef int32_t FileFd;
|
||||
typedef int32_t SocketFd;
|
||||
#endif
|
||||
|
||||
#define FD_INITIALIZER ((int32_t)-1)
|
||||
|
|
|
@ -27,49 +27,33 @@ extern "C" {
|
|||
#include <Winsock2.h>
|
||||
#else
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/ip.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <netinet/udp.h>
|
||||
#include <sys/epoll.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
||||
#define taosSend(sockfd, buf, len, flags) send((SOCKET)sockfd, buf, len, flags)
|
||||
#define taosSendto(sockfd, buf, len, flags, dest_addr, addrlen) sendto((SOCKET)sockfd, buf, len, flags, dest_addr, addrlen)
|
||||
#define taosWriteSocket(fd, buf, len) send((SOCKET)fd, buf, len, 0)
|
||||
#define taosReadSocket(fd, buf, len) recv((SOCKET)fd, buf, len, 0)
|
||||
#define taosCloseSocketNoCheck(fd) closesocket((SOCKET)fd)
|
||||
#define taosCloseSocket(fd) closesocket((SOCKET)fd)
|
||||
#else
|
||||
#define taosSend(sockfd, buf, len, flags) send(sockfd, buf, len, flags)
|
||||
#define taosSendto(sockfd, buf, len, flags, dest_addr, addrlen) sendto(sockfd, buf, len, flags, dest_addr, addrlen)
|
||||
#define taosReadSocket(fd, buf, len) read(fd, buf, len)
|
||||
#define taosWriteSocket(fd, buf, len) write(fd, buf, len)
|
||||
#define taosCloseSocketNoCheck(x) close(x)
|
||||
#define taosCloseSocket(x) \
|
||||
{ \
|
||||
if ((x) > -1) { \
|
||||
close(x); \
|
||||
x = FD_INITIALIZER; \
|
||||
} \
|
||||
}
|
||||
#endif
|
||||
|
||||
#define TAOS_EPOLL_WAIT_TIME 500
|
||||
#define TAOS_EPOLL_WAIT_TIME 500
|
||||
typedef int32_t SOCKET;
|
||||
typedef SOCKET EpollFd;
|
||||
typedef SOCKET EpollFd;
|
||||
#define EpollClose(pollFd) taosCloseSocket(pollFd)
|
||||
|
||||
void taosShutDownSocketRD(SOCKET fd);
|
||||
void taosShutDownSocketWR(SOCKET fd);
|
||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
||||
typedef SOCKET SocketFd;
|
||||
#else
|
||||
typedef int32_t SocketFd;
|
||||
#endif
|
||||
|
||||
int32_t taosSendto(SocketFd fd, void * msg, int len, unsigned int flags, const struct sockaddr * to, int tolen);
|
||||
int32_t taosWriteSocket(SocketFd fd, void *msg, int len);
|
||||
int32_t taosReadSocket(SocketFd fd, void *msg, int len);
|
||||
int32_t taosCloseSocketNoCheck(SocketFd fd);
|
||||
int32_t taosCloseSocket(SocketFd fd);
|
||||
void taosShutDownSocketRD(SOCKET fd);
|
||||
void taosShutDownSocketWR(SOCKET fd);
|
||||
int32_t taosSetNonblocking(SOCKET sock, int32_t on);
|
||||
void taosIgnSIGPIPE();
|
||||
void taosBlockSIGPIPE();
|
||||
void taosSetMaskSIGPIPE();
|
||||
int32_t taosSetSockOpt(SOCKET socketfd, int32_t level, int32_t optname, void *optval, int32_t optlen);
|
||||
int32_t taosGetSockOpt(SOCKET socketfd, int32_t level, int32_t optname, void *optval, int32_t* optlen);
|
||||
int32_t taosGetSockOpt(SOCKET socketfd, int32_t level, int32_t optname, void *optval, int32_t *optlen);
|
||||
|
||||
uint32_t taosInetAddr(char *ipAddr);
|
||||
const char *taosInetNtoa(struct in_addr ipInt);
|
||||
|
|
|
@ -66,6 +66,8 @@ typedef struct {
|
|||
|
||||
SysNameInfo taosGetSysNameInfo();
|
||||
|
||||
int64_t taosGetPid();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -695,7 +695,7 @@ static SRpcConn *rpcAllocateClientConn(SRpcInfo *pRpc) {
|
|||
pConn->sid = sid;
|
||||
pConn->tranId = (uint16_t)(taosRand() & 0xFFFF);
|
||||
pConn->ownId = htonl(pConn->sid);
|
||||
pConn->linkUid = (uint32_t)((int64_t)pConn + (int64_t)getpid() + (int64_t)pConn->tranId);
|
||||
pConn->linkUid = (uint32_t)((int64_t)pConn + taosGetPid() + (int64_t)pConn->tranId);
|
||||
pConn->spi = pRpc->spi;
|
||||
pConn->encrypt = pRpc->encrypt;
|
||||
if (pConn->spi) memcpy(pConn->secret, pRpc->secret, TSDB_KEY_LEN);
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
||||
#else
|
||||
#include <sys/file.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
uint32_t taosRand(void) { return rand(); }
|
||||
|
|
|
@ -376,6 +376,7 @@ int32_t taosGetCurrentAPPName(char *name, int32_t *len) {
|
|||
*/
|
||||
|
||||
#include <sys/syscall.h>
|
||||
#include <unistd.h>
|
||||
|
||||
bool taosCheckPthreadValid(pthread_t thread) { return thread != 0; }
|
||||
|
||||
|
|
|
@ -22,6 +22,8 @@ void taosMsleep(int32_t ms) { Sleep(ms); }
|
|||
|
||||
#else
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
/*
|
||||
to make taosMsleep work,
|
||||
signal SIGALRM shall be blocked in the calling thread,
|
||||
|
|
|
@ -17,16 +17,57 @@
|
|||
#include "os.h"
|
||||
|
||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
||||
#include "winsock2.h"
|
||||
#include <WS2tcpip.h>
|
||||
#include <winbase.h>
|
||||
#include <Winsock2.h>
|
||||
#else
|
||||
#include <arpa/inet.h>
|
||||
#include <fcntl.h>
|
||||
#include <netdb.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/ip.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <netinet/udp.h>
|
||||
#include <sys/socket.h>
|
||||
#include <unistd.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <fcntl.h>
|
||||
#include <netdb.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/ip.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <netinet/udp.h>
|
||||
#include <sys/socket.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
||||
|
||||
#define taosSend(sockfd, buf, len, flags) send((SOCKET)sockfd, buf, len, flags)
|
||||
int32_t taosSendto(SocketFd fd, void *buf, int len, unsigned int flags, const struct sockaddr *to, int tolen) {
|
||||
return sendto((SOCKET)sockfd, buf, len, flags, dest_addr, addrlen);
|
||||
}
|
||||
int32_t taosWriteSocket(SocketFd fd, void *buf, int len) { return send((SOCKET)fd, buf, len, 0); }
|
||||
int32_t taosReadSocket(SocketFd fd, void *buf, int len) { return recv((SOCKET)fd, buf, len, 0)(); }
|
||||
int32_t taosCloseSocketNoCheck(SocketFd fd) { return closesocket((SOCKET)fd); }
|
||||
int32_t taosCloseSocket(SocketFd fd) { closesocket((SOCKET)fd) }
|
||||
|
||||
#else
|
||||
|
||||
#define taosSend(sockfd, buf, len, flags) send(sockfd, buf, len, flags)
|
||||
int32_t taosSendto(SocketFd fd, void * buf, int len, unsigned int flags, const struct sockaddr * dest_addr, int addrlen) {
|
||||
return sendto(fd, buf, len, flags, dest_addr, addrlen);
|
||||
}
|
||||
|
||||
int32_t taosWriteSocket(SocketFd fd, void *buf, int len) {
|
||||
return write(fd, buf, len);
|
||||
}
|
||||
|
||||
int32_t taosReadSocket(SocketFd fd, void *buf, int len) {
|
||||
return read(fd, buf, len);
|
||||
}
|
||||
|
||||
int32_t taosCloseSocketNoCheck(SocketFd fd) {
|
||||
return close(fd);
|
||||
}
|
||||
|
||||
int32_t taosCloseSocket(SocketFd fd) {
|
||||
if (fd > -1) {
|
||||
close(fd);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void taosShutDownSocketRD(SOCKET fd) {
|
||||
|
@ -226,8 +267,6 @@ uint64_t htonll(uint64_t val) { return (((uint64_t)htonl(val)) << 32) + htonl(va
|
|||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifndef SIGPIPE
|
||||
#define SIGPIPE EPIPE
|
||||
#endif
|
||||
|
|
|
@ -485,6 +485,7 @@ char *taosGetCmdlineByPID(int pid) {
|
|||
#include <sys/statvfs.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <sys/utsname.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define PROCESS_ITEM 12
|
||||
|
||||
|
@ -1127,4 +1128,9 @@ SysNameInfo taosGetSysNameInfo() {
|
|||
|
||||
return info;
|
||||
}
|
||||
|
||||
int64_t taosGetPid() {
|
||||
getpid();
|
||||
}
|
||||
|
||||
#endif
|
|
@ -62,6 +62,7 @@ void taosUninitTimer() {
|
|||
|
||||
#include <sys/syscall.h>
|
||||
#include <sys/event.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static void (*timer_callback)(int);
|
||||
static int timer_ms = 0;
|
||||
|
@ -136,6 +137,7 @@ void taos_block_sigalrm(void) {
|
|||
*/
|
||||
|
||||
#include <sys/syscall.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static void taosDeleteTimer(void *tharg) {
|
||||
timer_t *pTimer = tharg;
|
||||
|
|
|
@ -210,7 +210,7 @@ static void dnodeSendTelemetryReport(DnTelem* telem) {
|
|||
"Content-Type: application/json\n"
|
||||
"Content-Length: ";
|
||||
|
||||
taosWriteSocket(fd, header, (int32_t)strlen(header));
|
||||
taosWriteSocket(fd, (void*)header, (int32_t)strlen(header));
|
||||
int32_t contLen = (int32_t)(tbufTell(&bw) - 1);
|
||||
sprintf(buf, "%d\n\n", contLen);
|
||||
taosWriteSocket(fd, buf, (int32_t)strlen(buf));
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
static int32_t tsFileRsetId = -1;
|
||||
|
||||
static void tfCloseFile(void *p) {
|
||||
close((int32_t)(uintptr_t)p);
|
||||
taosCloseFile((int32_t)(uintptr_t)p);
|
||||
}
|
||||
|
||||
int32_t tfInit() {
|
||||
|
@ -48,7 +48,7 @@ static int64_t tfOpenImp(int32_t fd) {
|
|||
|
||||
void * p = (void *)(int64_t)fd;
|
||||
int64_t rid = taosAddRef(tsFileRsetId, p);
|
||||
if (rid < 0) close(fd);
|
||||
if (rid < 0) taosCloseFile(fd);
|
||||
|
||||
return rid;
|
||||
}
|
||||
|
|
|
@ -100,7 +100,7 @@ static void *taosThreadToOpenNewNote(void *param) {
|
|||
}
|
||||
|
||||
taosLockNote(fd, pNote);
|
||||
(void)lseek(fd, 0, SEEK_SET);
|
||||
(void)taosLSeekFile(fd, 0, SEEK_SET);
|
||||
|
||||
int32_t oldFd = pNote->fd;
|
||||
pNote->fd = fd;
|
||||
|
@ -142,10 +142,10 @@ static bool taosCheckNoteIsOpen(char *noteName, SNoteObj *pNote) {
|
|||
|
||||
if (taosLockNote(fd, pNote)) {
|
||||
taosUnLockNote(fd, pNote);
|
||||
close(fd);
|
||||
taosCloseFile(fd);
|
||||
return false;
|
||||
} else {
|
||||
close(fd);
|
||||
taosCloseFile(fd);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -226,7 +226,7 @@ static int32_t taosOpenNoteWithMaxLines(char *fn, int32_t maxLines, int32_t maxN
|
|||
size = (int32_t)filestat_size;
|
||||
pNote->lines = size / 60;
|
||||
|
||||
lseek(pNote->fd, 0, SEEK_END);
|
||||
taosLSeekFile(pNote->fd, 0, SEEK_END);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -271,6 +271,6 @@ void taosNotePrint(SNoteObj *pNote, const char *const format, ...) {
|
|||
static void taosCloseNoteByFd(int32_t fd, SNoteObj *pNote) {
|
||||
if (fd >= 0) {
|
||||
taosUnLockNote(fd, pNote);
|
||||
close(fd);
|
||||
taosCloseFile(fd);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue