Fixes Solaris build warnings

(closes issue #10698, reported and patched by snuffy)



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@82283 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Mark Michelson
2007-09-12 16:24:45 +00:00
parent 99fb378cdc
commit 3a6e79ad80
3 changed files with 13 additions and 2 deletions

View File

@@ -39,6 +39,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include <sys/stat.h>
#include <sys/file.h>
#include <regex.h>
#include <fcntl.h>
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
@@ -1146,8 +1147,14 @@ static enum AST_LOCK_RESULT ast_lock_path_flock(const char *path)
pl->path = strdup(path);
time(&start);
while (((res = flock(pl->fd, LOCK_EX | LOCK_NB)) < 0) &&
(errno == EWOULDBLOCK) && (time(NULL) - start < 5))
while ((
#ifdef SOLARIS
(res = fcntl(pl->fd, F_SETLK, fcntl(pl->fd,F_GETFL)|O_NONBLOCK)) < 0) &&
#else
(res = flock(pl->fd, LOCK_EX | LOCK_NB)) < 0) &&
#endif
(errno == EWOULDBLOCK) &&
(time(NULL) - start < 5))
usleep(1000);
if (res) {
ast_log(LOG_WARNING, "Failed to lock path '%s': %s\n",