[stsf-commit] stsf/STFontServer/loader client.c, 1.1.1.1,
1.2 makefile, 1.2, 1.3 stfsloader.c, 1.2, 1.3 stfsloader.x,
1.1.1.1, 1.2
Alexander Gelfenbain
stsf-commit at pdx.freedesktop.org
Thu Jul 1 22:00:16 PDT 2004
- Previous message: [stsf-commit] stsf/STFontServer/dropins/freetype2 ft2_glue.c, 1.3,
1.4 ftrenderglyph.inc, 1.1.1.1, 1.2 makefile, 1.1.1.1,
1.2 testft2.c, 1.1.1.1, 1.2
- Next message: [stsf-commit] stsf/interface VERSION, 1.2, 1.3 config.h.in, 1.3,
1.4 fontserver.h, 1.4, 1.5 genversion.py, 1.2, 1.3 makefile,
1.7, 1.8 st.h, 1.2, 1.3 stprivate.h, 1.2, 1.3 sttypes.tmpl, 1.8, 1.9
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Committed by: adg
Index: client.c
===================================================================
RCS file: /cvs/stsf/stsf/STFontServer/loader/client.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- client.c 26 Mar 2004 19:19:56 -0000 1.1.1.1
+++ client.c 2 Jul 2004 05:00:13 -0000 1.2
@@ -30,11 +30,6 @@
* INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE
* THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE
* SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * You acknowledge that this software is not designed, licensed or intended
- * for use in the design, construction, operation or maintenance of any
- * nuclear facility.
- *
*/
/* $Id$ */
@@ -43,7 +38,7 @@
* @file client.c
* @brief RPC STSF Font Server Loader test program
* @author Alexander Gelfenbain <adg at sun.com>
- * @version 0.8
+ * @version 0.11
*/
Index: makefile
===================================================================
RCS file: /cvs/stsf/stsf/STFontServer/loader/makefile,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- makefile 8 Apr 2004 01:40:55 -0000 1.2
+++ makefile 2 Jul 2004 05:00:13 -0000 1.3
@@ -30,11 +30,6 @@
# THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE
# SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
#
-# You acknowledge that this software is not designed, licensed or intended
-# for use in the design, construction, operation or maintenance of any
-# nuclear facility.
-#
-#
# $Id$
TOP=../..
@@ -45,7 +40,7 @@
PROGS = stfsloader
LIBS_RPC = -lnsl -ldoor
-LIBS = -L$(TOP)/stsflib -lstsf
+#LIBS = -L$(TOP)/stsflib -lstsf
#CFLAGS += -DDEBUG
Index: stfsloader.c
===================================================================
RCS file: /cvs/stsf/stsf/STFontServer/loader/stfsloader.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- stfsloader.c 25 May 2004 02:47:24 -0000 1.2
+++ stfsloader.c 2 Jul 2004 05:00:13 -0000 1.3
@@ -30,11 +30,6 @@
* INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE
* THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE
* SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * You acknowledge that this software is not designed, licensed or intended
- * for use in the design, construction, operation or maintenance of any
- * nuclear facility.
- *
*/
/* $Id$ */
@@ -43,7 +38,7 @@
* @file stfsloader.c
* @brief An RPC-based ST Font Server Loader
* @author Alexander Gelfenbain <adg at sun.com>
- * @version 0.8
+ * @version 0.11
*/
#include <rpc/rpc.h>
@@ -53,7 +48,9 @@
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
+#include <sys/stat.h>
#include <signal.h>
+#include <fcntl.h>
#include "fscomm.h"
#include "sttypes.h"
@@ -83,13 +80,13 @@
sigrelse(SIGINT); sigrelse(SIGPIPE); sigrelse(SIGALRM); sigrelse(SIGPOLL);
if (ret == -1) {
- ErrorStr("%s: door_call error.", __func__);
+ printf("%s: door_call error.", __func__);
perror("door_call");
return 1;
}
if (arg.rbuf != *buf) {
- DebugStr(1, "door_call allocated rbuf");
+ printf("door_call allocated rbuf");
munmap(*buf, *bufsize);
*buf = arg.rbuf;
*bufsize = arg.rsize;
@@ -106,24 +103,23 @@
#define PBUFSIZE 1024
+/* returns: 0: OK, 1: error, 2: version mismatch */
int checkserver(void)
{
int fd = open(STFS_DOOR, O_RDWR);
char *pbuf = NULL; /* buffer for protocol */
size_t pbufsize = PBUFSIZE;
int opcode, nbytes;
- int ret;
+ int ret = 1; /* error checking status */
DoorHandshakeIn *hin;
DoorHandshakeOut *hout;
if (fd == -1) {
- ret = 1;
goto cleanup;
}
if ((pbuf = mmap(0, pbufsize, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0)) == MAP_FAILED) {
perror("mmap");
- ret = 1;
goto cleanup;
}
@@ -138,21 +134,23 @@
hin->proto = STFS_PROTOCOL_VERSION;
if (fsexchange(fd, &pbuf, &pbufsize, NULL, NULL)) {
- ErrorStr("%s: fsexchange failed.", __func__);
- ret = ST_PROTO_ERROR;
+ printf("%s: fsexchange failed.", __func__);
goto cleanup;
}
hout = (DoorHandshakeOut *) pbuf;
- if (hout->opcode != HANDSHAKE_VERIFY_REPLY || hout->ret != ST_OK) {
+ if (hout->opcode != HANDSHAKE_VERIFY_REPLY) {
unlink(STFS_DOOR);
- ret = 1;
goto cleanup;
}
- /* XXX need to check the STFS version number here */
- ret = 0;
+ if (hout->ret == ST_RANGE) {
+ /* version mismatch */
+ ret = 2;
+ } else if (hout->ret == ST_OK) {
+ ret = 0;
+ }
cleanup:
if (pbuf != NULL) {
@@ -166,22 +164,66 @@
return ret;
}
+/* returns pid of the stfontserverd or 0 if it is not running */
+pid_t trylock(const char *filename)
+{
+ struct flock lock;
+ int fd = open(filename, O_RDWR);
+
+ if (fd == -1) {
+ return (pid_t) 0;
+ }
+ lock.l_type = F_WRLCK;
+ lock.l_start = 0;
+ lock.l_whence = SEEK_SET;
+ lock.l_len = 0;
+
+ if (fcntl(fd, F_GETLK, &lock) < 0) {
+ perror("fcntl");
+ return (pid_t) -1;
+ }
+
+ if (lock.l_type == F_UNLCK) {
+ return (pid_t) 0;
+ }
+
+ return lock.l_pid;
+}
+
stfsloader_out *loadstfontserver_1_svc(stfsloader_in *inp, struct svc_req *rqstp)
{
static stfsloader_out out;
pid_t child;
+ pid_t stfontserverd = trylock(STFONTSERVERD_PIDFILE);
+ int k;
int timeout = 10000;
+ struct stat st;
- strlcpy(out.doorname, STFS_DOOR, MAXDOORNAME);
+ out.doorname[0] = '\0';
- if (!checkserver()) {
- /* printf("stfontserverd has already been started.\n\n"); */
- out.rescode = FSLOADER_ALREADY;
- return &out;
+ if (stfontserverd != (pid_t) 0 && stfontserverd != (pid_t) -1) {
+ /* server is running */
+ k = checkserver();
+
+ if (k == 0) {
+ printf("stfontserverd has already been started.\n\n");
+ out.rescode = FSLOADER_ALREADY;
+ strlcpy(out.doorname, STFS_DOOR, MAXDOORNAME);
+ return &out;
+ } else {
+ /* the server is running but something wrong is going with it (otherwise stfsloader
+ would not have been called into action to start it), so we might as well kill it
+ and attempt to start it again */
+ printf("killing stfontserverd\n");
+ kill(stfontserverd, 9);
+ }
}
- /* printf("stfontserverd is being started.\n\n"); */
+ /* unlink the door file just in case stfontserverd died without cleaning up after itself */
+ unlink(STFS_DOOR);
+
+ printf("stfontserverd is being started.\n\n");
if ((child = fork()) == 0) {
execl(STFONTSERVERD_PATH, STFONTSERVERD_NAME, NULL);
@@ -201,7 +243,7 @@
returns the door is already there so the watchdog will not load stfontserverd twice.
Will fix it before FCS */
- while (FileType(STFS_DOOR) == ST_FILETYPE_DOESNOTEXIST) {
+ while (stat(STFS_DOOR, &st) < 0) {
usleep(10000);
if (!(timeout--)) {
out.rescode = FSLOADER_FAILED;
@@ -210,6 +252,7 @@
}
out.rescode = FSLOADER_LOADED;
+ strlcpy(out.doorname, STFS_DOOR, MAXDOORNAME);
return &out;
}
Index: stfsloader.x
===================================================================
RCS file: /cvs/stsf/stsf/STFontServer/loader/stfsloader.x,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- stfsloader.x 26 Mar 2004 19:19:56 -0000 1.1.1.1
+++ stfsloader.x 2 Jul 2004 05:00:13 -0000 1.2
@@ -30,11 +30,6 @@
* INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE
* THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE
* SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * You acknowledge that this software is not designed, licensed or intended
- * for use in the design, construction, operation or maintenance of any
- * nuclear facility.
- *
*/
/* $Id$ */
@@ -43,7 +38,7 @@
* @file stfsloader.x
* @brief RPC interface definition for ST Font Server Loader
* @author Alexander Gelfenbain <adg at sun.com>
- * @version 0.8
+ * @version 0.11
*/
- Previous message: [stsf-commit] stsf/STFontServer/dropins/freetype2 ft2_glue.c, 1.3,
1.4 ftrenderglyph.inc, 1.1.1.1, 1.2 makefile, 1.1.1.1,
1.2 testft2.c, 1.1.1.1, 1.2
- Next message: [stsf-commit] stsf/interface VERSION, 1.2, 1.3 config.h.in, 1.3,
1.4 fontserver.h, 1.4, 1.5 genversion.py, 1.2, 1.3 makefile,
1.7, 1.8 st.h, 1.2, 1.3 stprivate.h, 1.2, 1.3 sttypes.tmpl, 1.8, 1.9
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the stsf-commit
mailing list