summaryrefslogtreecommitdiffstats
path: root/contrib/sendmail/src/shmticklib.c
diff options
context:
space:
mode:
authorgshapiro <gshapiro@FreeBSD.org>2000-08-12 21:55:49 +0000
committergshapiro <gshapiro@FreeBSD.org>2000-08-12 21:55:49 +0000
commit4332139a9a11f773ffe5109bed871561e3c290a1 (patch)
tree6d207932926718f38869bd08959330c09f4f3e0d /contrib/sendmail/src/shmticklib.c
parenta392fe0bdb7081117c445f5dcc98d5ed4013dc17 (diff)
downloadFreeBSD-src-4332139a9a11f773ffe5109bed871561e3c290a1.zip
FreeBSD-src-4332139a9a11f773ffe5109bed871561e3c290a1.tar.gz
Import of sendmail version 8.11.0 into vendor branch SENDMAIL with
release tag v8_11_0. Obtained from: ftp://ftp.sendmail.org/pub/sendmail/
Diffstat (limited to 'contrib/sendmail/src/shmticklib.c')
-rw-r--r--contrib/sendmail/src/shmticklib.c84
1 files changed, 84 insertions, 0 deletions
diff --git a/contrib/sendmail/src/shmticklib.c b/contrib/sendmail/src/shmticklib.c
new file mode 100644
index 0000000..a3e1ad5
--- /dev/null
+++ b/contrib/sendmail/src/shmticklib.c
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 1999-2000 Sendmail, Inc. and its suppliers.
+ * All rights reserved.
+ *
+ * By using this file, you agree to the terms and conditions set
+ * forth in the LICENSE file which can be found at the top level of
+ * the sendmail distribution.
+ *
+ * Contributed by Exactis.com, Inc.
+ *
+ */
+
+#ifndef lint
+static char id[] = "@(#)$Id: shmticklib.c,v 8.6 2000/02/26 01:32:27 gshapiro Exp $";
+#endif /* ! lint */
+
+#if _FFR_SHM_STATUS
+# if SFIO
+# include <sfio/stdio.h>
+# else /* !SFIO */
+# include <stdio.h>
+# endif /* SFIO */
+# include <sys/types.h>
+# include <sys/ipc.h>
+# include <sys/shm.h>
+
+# include "statusd_shm.h"
+
+ /*
+** SHMTICK -- increment a shared memory variable
+**
+** Parameters:
+** inc_me -- identity of shared memory segment
+** what -- which variable to increment
+**
+** Returns:
+** none
+*/
+
+void
+shmtick(inc_me, what)
+ int inc_me;
+ int what;
+{
+ static int shmid = -1;
+ static STATUSD_SHM *sp = (STATUSD_SHM *)-1;
+ static unsigned int cookie = 0;
+
+ if (shmid < 0)
+ {
+ int size = sizeof(STATUSD_SHM);
+
+ shmid = shmget(STATUSD_SHM_KEY, size, 0);
+ if (shmid < 0)
+ return;
+ }
+ if ((unsigned long *)sp == (unsigned long *)-1)
+ {
+ sp = (STATUSD_SHM *)shmat(shmid, NULL, 0);
+ if ((unsigned long *)sp == (unsigned long *)-1)
+ return;
+ }
+ if (sp->magic != STATUSD_MAGIC)
+ {
+ /*
+ ** possible race condition, wait for
+ ** statusd to initialize.
+ */
+
+ return;
+ }
+ if (what >= STATUSD_LONGS)
+ what = STATUSD_LONGS - 1;
+ if (inc_me >= STATUSD_LONGS)
+ inc_me = STATUSD_LONGS - 1;
+
+ if (sp->ul[STATUSD_COOKIE] != cookie)
+ {
+ cookie = sp->ul[STATUSD_COOKIE];
+ ++(sp->ul[inc_me]);
+ }
+ ++(sp->ul[what]);
+}
+#endif /* _FFR_SHM_STATUS */
OpenPOWER on IntegriCloud