commit
dc11aa28ba
|
@ -31,10 +31,14 @@ extern "C" {
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t taosRead(int32_t fd, void *buf, int64_t count);
|
int64_t taosReadImp(int32_t fd, void *buf, int64_t count);
|
||||||
int64_t taosWrite(int32_t fd, void *buf, int64_t count);
|
int64_t taosWriteImp(int32_t fd, void *buf, int64_t count);
|
||||||
int64_t taosLSeek(int32_t fd, int64_t offset, int32_t whence);
|
int64_t taosLSeekImp(int32_t fd, int64_t offset, int32_t whence);
|
||||||
int32_t taosRenameFile(char *fullPath, char *suffix, char delimiter, char **dstPath);
|
int32_t taosRenameFile(char *fullPath, char *suffix, char delimiter, char **dstPath);
|
||||||
|
|
||||||
|
#define taosRead(fd, buf, count) taosReadImp(fd, buf, count)
|
||||||
|
#define taosWrite(fd, buf, count) taosWriteImp(fd, buf, count)
|
||||||
|
#define taosLSeek(fd, offset, whence) taosLSeekImp(fd, offset, whence)
|
||||||
#define taosClose(x) tclose(x)
|
#define taosClose(x) tclose(x)
|
||||||
|
|
||||||
// TAOS_OS_FUNC_FILE_SENDIFLE
|
// TAOS_OS_FUNC_FILE_SENDIFLE
|
||||||
|
@ -42,12 +46,12 @@ int64_t taosSendFile(int32_t dfd, int32_t sfd, int64_t *offset, int64_t size);
|
||||||
int64_t taosFSendFile(FILE *outfile, FILE *infile, int64_t *offset, int64_t size);
|
int64_t taosFSendFile(FILE *outfile, FILE *infile, int64_t *offset, int64_t size);
|
||||||
|
|
||||||
#ifdef TAOS_RANDOM_FILE_FAIL
|
#ifdef TAOS_RANDOM_FILE_FAIL
|
||||||
void taosSetRandomFileFailFactor(int factor);
|
void taosSetRandomFileFailFactor(int32_t factor);
|
||||||
void taosSetRandomFileFailOutput(const char *path);
|
void taosSetRandomFileFailOutput(const char *path);
|
||||||
#ifdef TAOS_RANDOM_FILE_FAIL_TEST
|
#ifdef TAOS_RANDOM_FILE_FAIL_TEST
|
||||||
ssize_t taosReadFileRandomFail(int fd, void *buf, size_t count, const char *file, uint32_t line);
|
int64_t taosReadFileRandomFail(int32_t fd, void *buf, int32_t count, const char *file, uint32_t line);
|
||||||
ssize_t taosWriteFileRandomFail(int fd, void *buf, size_t count, const char *file, uint32_t line);
|
int64_t taosWriteFileRandomFail(int32_t fd, void *buf, int32_t count, const char *file, uint32_t line);
|
||||||
off_t taosLSeekRandomFail(int fd, off_t offset, int whence, const char *file, uint32_t line);
|
int64_t taosLSeekRandomFail(int32_t fd, int64_t offset, int32_t whence, const char *file, uint32_t line);
|
||||||
#undef taosRead
|
#undef taosRead
|
||||||
#undef taosWrite
|
#undef taosWrite
|
||||||
#undef taosLSeek
|
#undef taosLSeek
|
||||||
|
|
|
@ -42,10 +42,10 @@ extern "C" {
|
||||||
|
|
||||||
#ifdef TAOS_RANDOM_NETWORK_FAIL
|
#ifdef TAOS_RANDOM_NETWORK_FAIL
|
||||||
#ifdef TAOS_RANDOM_NETWORK_FAIL_TEST
|
#ifdef TAOS_RANDOM_NETWORK_FAIL_TEST
|
||||||
ssize_t taosSendRandomFail(int32_t sockfd, const void *buf, size_t len, int32_t flags);
|
int64_t taosSendRandomFail(int32_t sockfd, const void *buf, size_t len, int32_t flags);
|
||||||
ssize_t taosSendToRandomFail(int32_t sockfd, const void *buf, size_t len, int32_t flags, const struct sockaddr *dest_addr, socklen_t addrlen);
|
int64_t taosSendToRandomFail(int32_t sockfd, const void *buf, size_t len, int32_t flags, const struct sockaddr *dest_addr, socklen_t addrlen);
|
||||||
ssize_t taosReadSocketRandomFail(int32_t fd, void *buf, size_t count);
|
int64_t taosReadSocketRandomFail(int32_t fd, void *buf, size_t count);
|
||||||
ssize_t taosWriteSocketRandomFail(int32_t fd, const void *buf, size_t count);
|
int64_t taosWriteSocketRandomFail(int32_t fd, const void *buf, size_t count);
|
||||||
#undef taosSend
|
#undef taosSend
|
||||||
#undef taosSendto
|
#undef taosSendto
|
||||||
#undef taosReadSocket
|
#undef taosReadSocket
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
#ifdef TAOS_RANDOM_NETWORK_FAIL
|
#ifdef TAOS_RANDOM_NETWORK_FAIL
|
||||||
|
|
||||||
ssize_t taosSendRandomFail(int32_t sockfd, const void *buf, size_t len, int32_t flags) {
|
int64_t taosSendRandomFail(int32_t sockfd, const void *buf, size_t len, int32_t flags) {
|
||||||
if (rand() % RANDOM_NETWORK_FAIL_FACTOR == 0) {
|
if (rand() % RANDOM_NETWORK_FAIL_FACTOR == 0) {
|
||||||
errno = ECONNRESET;
|
errno = ECONNRESET;
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -29,8 +29,8 @@ ssize_t taosSendRandomFail(int32_t sockfd, const void *buf, size_t len, int32_t
|
||||||
return send(sockfd, buf, len, flags);
|
return send(sockfd, buf, len, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t taosSendToRandomFail(int32_t sockfd, const void *buf, size_t len, int32_t flags, const struct sockaddr *dest_addr,
|
int64_t taosSendToRandomFail(int32_t sockfd, const void *buf, size_t len, int32_t flags,
|
||||||
socklen_t addrlen) {
|
const struct sockaddr *dest_addr, socklen_t addrlen) {
|
||||||
if (rand() % RANDOM_NETWORK_FAIL_FACTOR == 0) {
|
if (rand() % RANDOM_NETWORK_FAIL_FACTOR == 0) {
|
||||||
errno = ECONNRESET;
|
errno = ECONNRESET;
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -39,7 +39,7 @@ ssize_t taosSendToRandomFail(int32_t sockfd, const void *buf, size_t len, int32_
|
||||||
return sendto(sockfd, buf, len, flags, dest_addr, addrlen);
|
return sendto(sockfd, buf, len, flags, dest_addr, addrlen);
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t taosReadSocketRandomFail(int32_t fd, void *buf, size_t count) {
|
int64_t taosReadSocketRandomFail(int32_t fd, void *buf, size_t count) {
|
||||||
if (rand() % RANDOM_NETWORK_FAIL_FACTOR == 0) {
|
if (rand() % RANDOM_NETWORK_FAIL_FACTOR == 0) {
|
||||||
errno = ECONNRESET;
|
errno = ECONNRESET;
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -48,7 +48,7 @@ ssize_t taosReadSocketRandomFail(int32_t fd, void *buf, size_t count) {
|
||||||
return read(fd, buf, count);
|
return read(fd, buf, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t taosWriteSocketRandomFail(int32_t fd, const void *buf, size_t count) {
|
int64_t taosWriteSocketRandomFail(int32_t fd, const void *buf, size_t count) {
|
||||||
if (rand() % RANDOM_NETWORK_FAIL_FACTOR == 0) {
|
if (rand() % RANDOM_NETWORK_FAIL_FACTOR == 0) {
|
||||||
errno = EINTR;
|
errno = EINTR;
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -105,7 +105,7 @@ void taosSetRandomFileFailOutput(const char *path) {
|
||||||
sigaction(SIGILL, &act, NULL);
|
sigaction(SIGILL, &act, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t taosReadFileRandomFail(int32_t fd, void *buf, size_t count, const char *file, uint32_t line) {
|
int64_t taosReadFileRandomFail(int32_t fd, void *buf, int32_t count, const char *file, uint32_t line) {
|
||||||
if (random_file_fail_factor > 0) {
|
if (random_file_fail_factor > 0) {
|
||||||
if (rand() % random_file_fail_factor == 0) {
|
if (rand() % random_file_fail_factor == 0) {
|
||||||
errno = EIO;
|
errno = EIO;
|
||||||
|
@ -113,10 +113,10 @@ ssize_t taosReadFileRandomFail(int32_t fd, void *buf, size_t count, const char *
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return taosRead(fd, buf, count);
|
return taosReadImp(fd, buf, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t taosWriteFileRandomFail(int32_t fd, void *buf, size_t count, const char *file, uint32_t line) {
|
int64_t taosWriteFileRandomFail(int32_t fd, void *buf, int32_t count, const char *file, uint32_t line) {
|
||||||
if (random_file_fail_factor > 0) {
|
if (random_file_fail_factor > 0) {
|
||||||
if (rand() % random_file_fail_factor == 0) {
|
if (rand() % random_file_fail_factor == 0) {
|
||||||
errno = EIO;
|
errno = EIO;
|
||||||
|
@ -124,10 +124,10 @@ ssize_t taosWriteFileRandomFail(int32_t fd, void *buf, size_t count, const char
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return taosWrite(fd, buf, count);
|
return taosWriteImp(fd, buf, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
off_t taosLSeekRandomFail(int32_t fd, off_t offset, int32_t whence, const char *file, uint32_t line) {
|
int64_t taosLSeekRandomFail(int32_t fd, int64_t offset, int32_t whence, const char *file, uint32_t line) {
|
||||||
if (random_file_fail_factor > 0) {
|
if (random_file_fail_factor > 0) {
|
||||||
if (rand() % random_file_fail_factor == 0) {
|
if (rand() % random_file_fail_factor == 0) {
|
||||||
errno = EIO;
|
errno = EIO;
|
||||||
|
@ -135,7 +135,7 @@ off_t taosLSeekRandomFail(int32_t fd, off_t offset, int32_t whence, const char *
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return taosLSeek(fd, offset, whence);
|
return taosLSeekImp(fd, offset, whence);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //TAOS_RANDOM_FILE_FAIL
|
#endif //TAOS_RANDOM_FILE_FAIL
|
||||||
|
|
|
@ -71,7 +71,7 @@ int32_t taosRenameFile(char *fullPath, char *suffix, char delimiter, char **dstP
|
||||||
return rename(fullPath, *dstPath);
|
return rename(fullPath, *dstPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t taosRead(int32_t fd, void *buf, int64_t count) {
|
int64_t taosReadImp(int32_t fd, void *buf, int64_t count) {
|
||||||
int64_t leftbytes = count;
|
int64_t leftbytes = count;
|
||||||
int64_t readbytes;
|
int64_t readbytes;
|
||||||
char * tbuf = (char *)buf;
|
char * tbuf = (char *)buf;
|
||||||
|
@ -95,7 +95,7 @@ int64_t taosRead(int32_t fd, void *buf, int64_t count) {
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t taosWrite(int32_t fd, void *buf, int64_t n) {
|
int64_t taosWriteImp(int32_t fd, void *buf, int64_t n) {
|
||||||
int64_t nleft = n;
|
int64_t nleft = n;
|
||||||
int64_t nwritten = 0;
|
int64_t nwritten = 0;
|
||||||
char * tbuf = (char *)buf;
|
char * tbuf = (char *)buf;
|
||||||
|
@ -115,6 +115,10 @@ int64_t taosWrite(int32_t fd, void *buf, int64_t n) {
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int64_t taosLSeekImp(int32_t fd, int64_t offset, int32_t whence) {
|
||||||
|
return (int64_t)tlseek(fd, (long)offset, whence);
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef TAOS_OS_FUNC_FILE_SENDIFLE
|
#ifndef TAOS_OS_FUNC_FILE_SENDIFLE
|
||||||
|
|
||||||
int64_t taosSendFile(int32_t dfd, int32_t sfd, int64_t *offset, int64_t size) {
|
int64_t taosSendFile(int32_t dfd, int32_t sfd, int64_t *offset, int64_t size) {
|
||||||
|
|
|
@ -13,10 +13,8 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include <regex.h>
|
|
||||||
|
|
||||||
#define TAOS_RANDOM_FILE_FAIL_TEST
|
#define TAOS_RANDOM_FILE_FAIL_TEST
|
||||||
|
#include <regex.h>
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "talgo.h"
|
#include "talgo.h"
|
||||||
#include "tchecksum.h"
|
#include "tchecksum.h"
|
||||||
|
|
|
@ -14,9 +14,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
|
|
||||||
#define TAOS_RANDOM_FILE_FAIL_TEST
|
#define TAOS_RANDOM_FILE_FAIL_TEST
|
||||||
|
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "talgo.h"
|
#include "talgo.h"
|
||||||
#include "tchecksum.h"
|
#include "tchecksum.h"
|
||||||
|
|
|
@ -14,9 +14,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
|
|
||||||
#define TAOS_RANDOM_FILE_FAIL_TEST
|
#define TAOS_RANDOM_FILE_FAIL_TEST
|
||||||
|
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "hash.h"
|
#include "hash.h"
|
||||||
#include "taoserror.h"
|
#include "taoserror.h"
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
|
#define TAOS_RANDOM_FILE_FAIL_TEST
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "taoserror.h"
|
#include "taoserror.h"
|
||||||
#include "tchecksum.h"
|
#include "tchecksum.h"
|
||||||
|
|
Loading…
Reference in New Issue