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:
parent
20ddcfb8c4
commit
d1772e300e
@ -263,6 +263,9 @@ typedef enum skygw_chk_t {
|
||||
(SERVER_IS_RELAY_SERVER(s) ? "RUNNING RELAY" : \
|
||||
(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" : \
|
||||
((t) == HINT_ROUTE_TO_SLAVE ? "HINT_ROUTE_TO_SLAVE" : \
|
||||
((t) == HINT_ROUTE_TO_NAMED_SERVER ? "HINT_ROUTE_TO_NAMED_SERVER" : \
|
||||
|
@ -1749,14 +1749,23 @@ 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,
|
||||
void* data,
|
||||
size_t nbytes,
|
||||
bool flush)
|
||||
{
|
||||
bool succp = false;
|
||||
int rc;
|
||||
#if !defined(LAPTOP_TEST)
|
||||
int err = 0;
|
||||
size_t nwritten;
|
||||
@ -1771,13 +1780,14 @@ bool skygw_file_write(
|
||||
nwritten = fwrite(data, nbytes, 1, file->sf_file);
|
||||
|
||||
if (nwritten != 1) {
|
||||
rc = errno;
|
||||
perror("Logfile write.\n");
|
||||
fprintf(stderr,
|
||||
"* Writing %ld bytes, %s to %s failed.\n",
|
||||
"* Writing %ld bytes,\n%s\n to %s failed.\n",
|
||||
nbytes,
|
||||
(char *)data,
|
||||
file->sf_fname);
|
||||
goto return_succp;
|
||||
goto return_rc;
|
||||
}
|
||||
writecount += 1;
|
||||
|
||||
@ -1789,10 +1799,10 @@ bool skygw_file_write(
|
||||
writecount = 0;
|
||||
}
|
||||
#endif
|
||||
succp = true;
|
||||
rc = 0;
|
||||
CHK_FILE(file);
|
||||
return_succp:
|
||||
return succp;
|
||||
return_rc:
|
||||
return rc;
|
||||
}
|
||||
|
||||
skygw_file_t* skygw_file_init(
|
||||
|
@ -146,7 +146,7 @@ EXTERN_C_BLOCK_END
|
||||
/** Skygw file routines */
|
||||
skygw_file_t* skygw_file_init(char* fname, char* symlinkname);
|
||||
void skygw_file_done(skygw_file_t* file);
|
||||
bool skygw_file_write(
|
||||
int skygw_file_write(
|
||||
skygw_file_t* file,
|
||||
void* data,
|
||||
size_t nbytes,
|
||||
|
Loading…
x
Reference in New Issue
Block a user