Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

Commit

Permalink
solaris fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ry committed Aug 2, 2011
1 parent 2e9a743 commit 22ec2db
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion config-unix.mk
Expand Up @@ -32,7 +32,7 @@ CPPFLAGS += -D_FILE_OFFSET_BITS=64
ifeq (SunOS,$(uname_S))
EV_CONFIG=config_sunos.h
EIO_CONFIG=config_sunos.h
CPPFLAGS += -Isrc/ares/config_sunos
CPPFLAGS += -Isrc/ares/config_sunos -D__EXTENSIONS__
LINKFLAGS+=-lsocket -lnsl
UV_OS_FILE=uv-sunos.c
endif
Expand Down
14 changes: 11 additions & 3 deletions src/uv-unix.c
Expand Up @@ -65,6 +65,7 @@
extern char **environ;
# endif

#define LOCKFILE_SUFFIX ".lock"

static uv_err_t last_err;

Expand Down Expand Up @@ -2236,6 +2237,7 @@ size_t uv__strlcpy(char* dst, const char* src, size_t size) {

uv_stream_t* uv_std_handle(uv_std_type type) {
assert(0 && "implement me");
return NULL;
}


Expand Down Expand Up @@ -2412,7 +2414,6 @@ int uv_process_kill(uv_process_t* process, int signum) {
}


#define LOCKFILE_SUFFIX ".lock"
int uv_flock_init(uv_flock_t* lock, const char* filename) {
int saved_errno;
int status;
Expand All @@ -2437,10 +2438,10 @@ int uv_flock_init(uv_flock_t* lock, const char* filename) {
errno = saved_errno;
return status;
}
#undef LOCKFILE_SUFFIX


int uv_flock_acquire(uv_flock_t* lock, int* locked_p) {
struct flock fl;
char buf[32];
int saved_errno;
int status;
Expand All @@ -2461,8 +2462,15 @@ int uv_flock_acquire(uv_flock_t* lock, int* locked_p) {
goto out;
}


fl.l_type = F_WRLCK;
fl.l_whence = SEEK_SET;
fl.l_start = 0;
fl.l_len = 0;
fl.l_pid = getpid();

do {
status = flock(lockfd, LOCK_EX | LOCK_NB);
status = fcntl(lockfd, F_SETLKW, &fl);
}
while (status == -1 && errno == EINTR);

Expand Down

0 comments on commit 22ec2db

Please sign in to comment.