Addition to fix to bug #613, http://bugs.skysql.com/show_bug.cgi?id=613
Added new declaration of skygw_file_write and modification to the function which returns errno instead of boolean.
This commit is contained in:
@ -263,6 +263,9 @@ typedef enum skygw_chk_t {
|
|||||||
(SERVER_IS_RELAY_SERVER(s) ? "RUNNING RELAY" : \
|
(SERVER_IS_RELAY_SERVER(s) ? "RUNNING RELAY" : \
|
||||||
(SERVER_IS_RUNNING(s) ? "RUNNING (only)" : "NO STATUS")))))))
|
(SERVER_IS_RUNNING(s) ? "RUNNING (only)" : "NO STATUS")))))))
|
||||||
|
|
||||||
|
#define BREFSRV(b) (b->bref_backend->backend_server)
|
||||||
|
|
||||||
|
|
||||||
#define STRHINTTYPE(t) (t == HINT_ROUTE_TO_MASTER ? "HINT_ROUTE_TO_MASTER" : \
|
#define STRHINTTYPE(t) (t == HINT_ROUTE_TO_MASTER ? "HINT_ROUTE_TO_MASTER" : \
|
||||||
((t) == HINT_ROUTE_TO_SLAVE ? "HINT_ROUTE_TO_SLAVE" : \
|
((t) == HINT_ROUTE_TO_SLAVE ? "HINT_ROUTE_TO_SLAVE" : \
|
||||||
((t) == HINT_ROUTE_TO_NAMED_SERVER ? "HINT_ROUTE_TO_NAMED_SERVER" : \
|
((t) == HINT_ROUTE_TO_NAMED_SERVER ? "HINT_ROUTE_TO_NAMED_SERVER" : \
|
||||||
|
|||||||
@ -1749,14 +1749,23 @@ return_succp:
|
|||||||
return succp;
|
return succp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
bool skygw_file_write(
|
* Write data to a file.
|
||||||
|
*
|
||||||
|
* @param file write target
|
||||||
|
* @param data pointer to contiguous memory buffer
|
||||||
|
* @param nbytes amount of bytes to be written
|
||||||
|
* @param flush ensure that write is permanent
|
||||||
|
*
|
||||||
|
* @return 0 if succeed, errno if failed.
|
||||||
|
*/
|
||||||
|
int skygw_file_write(
|
||||||
skygw_file_t* file,
|
skygw_file_t* file,
|
||||||
void* data,
|
void* data,
|
||||||
size_t nbytes,
|
size_t nbytes,
|
||||||
bool flush)
|
bool flush)
|
||||||
{
|
{
|
||||||
bool succp = false;
|
int rc;
|
||||||
#if !defined(LAPTOP_TEST)
|
#if !defined(LAPTOP_TEST)
|
||||||
int err = 0;
|
int err = 0;
|
||||||
size_t nwritten;
|
size_t nwritten;
|
||||||
@ -1771,13 +1780,14 @@ bool skygw_file_write(
|
|||||||
nwritten = fwrite(data, nbytes, 1, file->sf_file);
|
nwritten = fwrite(data, nbytes, 1, file->sf_file);
|
||||||
|
|
||||||
if (nwritten != 1) {
|
if (nwritten != 1) {
|
||||||
|
rc = errno;
|
||||||
perror("Logfile write.\n");
|
perror("Logfile write.\n");
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"* Writing %ld bytes, %s to %s failed.\n",
|
"* Writing %ld bytes,\n%s\n to %s failed.\n",
|
||||||
nbytes,
|
nbytes,
|
||||||
(char *)data,
|
(char *)data,
|
||||||
file->sf_fname);
|
file->sf_fname);
|
||||||
goto return_succp;
|
goto return_rc;
|
||||||
}
|
}
|
||||||
writecount += 1;
|
writecount += 1;
|
||||||
|
|
||||||
@ -1789,10 +1799,10 @@ bool skygw_file_write(
|
|||||||
writecount = 0;
|
writecount = 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
succp = true;
|
rc = 0;
|
||||||
CHK_FILE(file);
|
CHK_FILE(file);
|
||||||
return_succp:
|
return_rc:
|
||||||
return succp;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
skygw_file_t* skygw_file_init(
|
skygw_file_t* skygw_file_init(
|
||||||
|
|||||||
@ -146,7 +146,7 @@ EXTERN_C_BLOCK_END
|
|||||||
/** Skygw file routines */
|
/** Skygw file routines */
|
||||||
skygw_file_t* skygw_file_init(char* fname, char* symlinkname);
|
skygw_file_t* skygw_file_init(char* fname, char* symlinkname);
|
||||||
void skygw_file_done(skygw_file_t* file);
|
void skygw_file_done(skygw_file_t* file);
|
||||||
bool skygw_file_write(
|
int skygw_file_write(
|
||||||
skygw_file_t* file,
|
skygw_file_t* file,
|
||||||
void* data,
|
void* data,
|
||||||
size_t nbytes,
|
size_t nbytes,
|
||||||
|
|||||||
Reference in New Issue
Block a user