solaris portability fixes
git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@117 db0b04b0-f4d1-0310-9a6d-de3e77497b0e
This commit is contained in:
parent
9a272b46c6
commit
1059fae93b
|
@ -68,6 +68,7 @@
|
||||||
# define ARRAY_SIZE(x) sizeof(x) / sizeof(x[0])
|
# define ARRAY_SIZE(x) sizeof(x) / sizeof(x[0])
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <fcntl.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <grp.h>
|
#include <grp.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
@ -1060,7 +1061,8 @@ readfile (int nolock)
|
||||||
|
|
||||||
if (!nolock)
|
if (!nolock)
|
||||||
{
|
{
|
||||||
flock (fileno (fpl), LOCK_UN);
|
fl.l_type = F_UNLCK;
|
||||||
|
fcntl (fileno(fpl), F_SETLK, &fl);
|
||||||
fclose (fpl);
|
fclose (fpl);
|
||||||
}
|
}
|
||||||
fclose (fp);
|
fclose (fp);
|
||||||
|
@ -1162,13 +1164,21 @@ writefile (int requirenew)
|
||||||
FILE *fp, *fpl;
|
FILE *fp, *fpl;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int my_done = 0;
|
int my_done = 0;
|
||||||
|
struct flock fl = { 0 };
|
||||||
|
|
||||||
|
fl.l_type = F_WRLCK;
|
||||||
|
fl.l_whence = SEEK_SET;
|
||||||
|
fl.l_start = 0;
|
||||||
|
fl.l_len = 0;
|
||||||
|
|
||||||
fpl = fopen ("/dgl-lock", "r");
|
fpl = fopen ("/dgl-lock", "r");
|
||||||
if (!fpl)
|
if (!fpl)
|
||||||
graceful_exit (115);
|
graceful_exit (115);
|
||||||
if (flock (fileno (fpl), LOCK_EX))
|
if (fcntl (fileno (fpl), F_SETLK, &fl))
|
||||||
graceful_exit (107);
|
graceful_exit (107);
|
||||||
|
|
||||||
|
fl.l_type = F_UNLCK;
|
||||||
|
|
||||||
freefile ();
|
freefile ();
|
||||||
readfile (1);
|
readfile (1);
|
||||||
|
|
||||||
|
@ -1202,7 +1212,7 @@ writefile (int requirenew)
|
||||||
me->env);
|
me->env);
|
||||||
}
|
}
|
||||||
|
|
||||||
flock (fileno (fpl), LOCK_UN);
|
fcntl (fileno (fpl), F_UNLCK, &fl);
|
||||||
fclose (fp);
|
fclose (fp);
|
||||||
fclose (fpl);
|
fclose (fpl);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue