Fix log file being truncated on Windows.
This commit is contained in:
parent
c7d9cf3a3c
commit
0ce167c472
@ -8,6 +8,7 @@ Broker:
|
|||||||
- Various fixes around inflight quota management. Closes #2306.
|
- Various fixes around inflight quota management. Closes #2306.
|
||||||
- Fix problem parsing config files with Windows line endings. Closes #2297.
|
- Fix problem parsing config files with Windows line endings. Closes #2297.
|
||||||
- Don't send retained messages when a shared subscription is made.
|
- Don't send retained messages when a shared subscription is made.
|
||||||
|
- Fix log being truncated in Windows.
|
||||||
|
|
||||||
Client library:
|
Client library:
|
||||||
- Initialise sockpairR/W to invalid in `mosquitto_reinitialise()` to avoid
|
- Initialise sockpairR/W to invalid in `mosquitto_reinitialise()` to avoid
|
||||||
|
@ -32,6 +32,7 @@ Contributors:
|
|||||||
# include <aclapi.h>
|
# include <aclapi.h>
|
||||||
# include <io.h>
|
# include <io.h>
|
||||||
# include <lmcons.h>
|
# include <lmcons.h>
|
||||||
|
# include <fcntl.h>
|
||||||
#else
|
#else
|
||||||
# include <sys/stat.h>
|
# include <sys/stat.h>
|
||||||
#endif
|
#endif
|
||||||
@ -45,6 +46,8 @@ FILE *mosquitto__fopen(const char *path, const char *mode, bool restrict_read)
|
|||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
char buf[4096];
|
char buf[4096];
|
||||||
int rc;
|
int rc;
|
||||||
|
int flags = 0;
|
||||||
|
|
||||||
rc = ExpandEnvironmentStringsA(path, buf, 4096);
|
rc = ExpandEnvironmentStringsA(path, buf, 4096);
|
||||||
if(rc == 0 || rc > 4096){
|
if(rc == 0 || rc > 4096){
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -64,9 +67,11 @@ FILE *mosquitto__fopen(const char *path, const char *mode, bool restrict_read)
|
|||||||
switch(mode[0]){
|
switch(mode[0]){
|
||||||
case 'a':
|
case 'a':
|
||||||
dwCreationDisposition = OPEN_ALWAYS;
|
dwCreationDisposition = OPEN_ALWAYS;
|
||||||
|
flags = _O_APPEND;
|
||||||
break;
|
break;
|
||||||
case 'r':
|
case 'r':
|
||||||
dwCreationDisposition = OPEN_EXISTING;
|
dwCreationDisposition = OPEN_EXISTING;
|
||||||
|
flags = _O_RDONLY;
|
||||||
break;
|
break;
|
||||||
case 'w':
|
case 'w':
|
||||||
dwCreationDisposition = CREATE_ALWAYS;
|
dwCreationDisposition = CREATE_ALWAYS;
|
||||||
@ -88,6 +93,7 @@ FILE *mosquitto__fopen(const char *path, const char *mode, bool restrict_read)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
memset(&sec, 0, sizeof(sec));
|
||||||
sec.nLength = sizeof(SECURITY_ATTRIBUTES);
|
sec.nLength = sizeof(SECURITY_ATTRIBUTES);
|
||||||
sec.bInheritHandle = FALSE;
|
sec.bInheritHandle = FALSE;
|
||||||
sec.lpSecurityDescriptor = &sd;
|
sec.lpSecurityDescriptor = &sd;
|
||||||
@ -100,7 +106,7 @@ FILE *mosquitto__fopen(const char *path, const char *mode, bool restrict_read)
|
|||||||
|
|
||||||
LocalFree(pacl);
|
LocalFree(pacl);
|
||||||
|
|
||||||
fd = _open_osfhandle((intptr_t)hfile, 0);
|
fd = _open_osfhandle((intptr_t)hfile, flags);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user