fix issue where pid file is accidentally truncated (part2)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@10494 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
482c6491ac
commit
2c10f201e4
16
src/switch.c
16
src/switch.c
|
@ -610,14 +610,12 @@ int main(int argc, char *argv[])
|
||||||
pid_path,
|
pid_path,
|
||||||
SWITCH_FOPEN_READ,
|
SWITCH_FOPEN_READ,
|
||||||
SWITCH_FPROT_UREAD | SWITCH_FPROT_UWRITE,
|
SWITCH_FPROT_UREAD | SWITCH_FPROT_UWRITE,
|
||||||
pool) != SWITCH_STATUS_SUCCESS) {
|
pool) == SWITCH_STATUS_SUCCESS) {
|
||||||
fprintf(stderr, "Cannot open pid file %s.\n", pid_path);
|
|
||||||
return 255;
|
|
||||||
}
|
|
||||||
|
|
||||||
old_pid_len = sizeof(old_pid_buffer);
|
old_pid_len = sizeof(old_pid_buffer);
|
||||||
switch_file_read(fd, old_pid_buffer, &old_pid_len);
|
switch_file_read(fd, old_pid_buffer, &old_pid_len);
|
||||||
switch_file_close(fd);
|
switch_file_close(fd);
|
||||||
|
}
|
||||||
|
|
||||||
if (switch_file_open(&fd,
|
if (switch_file_open(&fd,
|
||||||
pid_path,
|
pid_path,
|
||||||
|
@ -631,7 +629,9 @@ int main(int argc, char *argv[])
|
||||||
if (switch_file_lock(fd, SWITCH_FLOCK_EXCLUSIVE | SWITCH_FLOCK_NONBLOCK) != SWITCH_STATUS_SUCCESS) {
|
if (switch_file_lock(fd, SWITCH_FLOCK_EXCLUSIVE | SWITCH_FLOCK_NONBLOCK) != SWITCH_STATUS_SUCCESS) {
|
||||||
fprintf(stderr, "Cannot lock pid file %s.\n", pid_path);
|
fprintf(stderr, "Cannot lock pid file %s.\n", pid_path);
|
||||||
old_pid_len = strlen(old_pid_buffer);
|
old_pid_len = strlen(old_pid_buffer);
|
||||||
switch_file_write(fd, old_pid_buffer, &old_pid_len);
|
if (strlen(old_pid_buffer)) {
|
||||||
|
switch_file_write(fd, old_pid_buffer, &old_pid_len);
|
||||||
|
}
|
||||||
return 255;
|
return 255;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue