#endif
#include "viced.h"
#include "host.h"
+#ifdef AFS_PTHREAD_ENV
+#include "softsig.h"
+#endif
#if defined(AFS_SGI_ENV)
#include "sys/schedctl.h"
#include "sys/lock.h"
extern int LogLevel;
extern int Statistics;
+int busyonrst = 1;
int timeout = 30;
int SawSpare;
int SawPctSpare;
int buffs = 90; /* 70 */
int novbc = 0; /* Enable Volume Break calls */
int busy_threshold = 600;
+int abort_threshold = 10;
int udpBufSize = 0; /* UDP buffer size for receive*/
int sendBufSize = 16384; /* send buffer size */
static void ResetCheckSignal(void)
{
-#ifdef AFS_HPUX_ENV
- signal(SIGPOLL, CheckSignal_Signal);
+ int signo;
+
+#if defined(AFS_HPUX_ENV)
+ signo = SIGPOLL;
#else
-#ifdef AFS_NT40_ENV
- signal(SIGUSR2, CheckSignal_Signal);
+#if defined(AFS_NT40_ENV)
+ signo = SIGUSR2;
#else
- signal(SIGXCPU, CheckSignal_Signal);
+ signo = SIGXCPU;
+#endif
#endif
+
+#if defined(AFS_PTHREAD_ENV)
+ softsig_signal(signo, CheckSignal_Signal);
+#else
+ signal(signo, CheckSignal_Signal);
#endif
}
static void ResetCheckDescriptors(void)
{
#ifndef AFS_NT40_ENV
+#if defined(AFS_PTHREAD_ENV)
+ softsig_signal(SIGTERM, CheckDescriptors_Signal);
+#else
signal(SIGTERM, CheckDescriptors_Signal);
#endif
+#endif
}
} /*CheckAdminName*/
-#ifdef AFS_PTHREAD_ENV
-/* A special LWP that will receive signals, to avoid deadlock */
-static void SignalLWP()
+static void setThreadId(char *s)
{
- sigset_t nsigset;
-
- sigfillset(&nsigset);
- assert(AFS_SET_SIGMASK(SIG_UNBLOCK, &nsigset, NULL) == 0);
-
- while (1)
- sleep(60);
-}
+#ifdef AFS_PTHREAD_ENV
+ /* set our 'thread-id' so that the host hold table works */
+ MUTEX_ENTER(&rx_stats_mutex); /* protects rxi_pthread_hinum */
+ ++rxi_pthread_hinum;
+ pthread_setspecific(rx_thread_id_key, (void *)rxi_pthread_hinum);
+ MUTEX_EXIT(&rx_stats_mutex);
+ ViceLog(0,("Set thread id %d for '%s'\n", pthread_getspecific(rx_thread_id_key), s));
#endif
-
+}
/* This LWP does things roughly every 5 minutes */
static void FiveMinuteCheckLWP()
char tbuffer[32];
ViceLog(1, ("Starting five minute check process\n"));
+ setThreadId("FiveMinuteCheckLWP");
while (1) {
#ifdef AFS_PTHREAD_ENV
sleep(fiveminutes);
static void HostCheckLWP()
{
ViceLog(1, ("Starting Host check process\n"));
+ setThreadId("HostCheckLWP");
while(1) {
#ifdef AFS_PTHREAD_ENV
sleep(fiveminutes);
#endif
ViceLog(1, ("Starting fsync check process\n"));
+ setThreadId("FsyncCheckLWP");
+
#ifdef AFS_PTHREAD_ENV
assert(pthread_cond_init(&fsync_cond, NULL) == 0);
assert(pthread_mutex_init(&fsync_glock_mutex, NULL) == 0);
strcat(buffer, "[-readonly (read-only file server)] ");
strcat(buffer, "[-hr <number of hours between refreshing the host cps>] ");
strcat(buffer, "[-busyat <redirect clients when queue > n>] ");
+ strcat(buffer, "[-nobusy <no VBUSY before a volume is attached>] ");
strcat(buffer, "[-rxpck <number of rx extra packets>] ");
strcat(buffer, "[-rxdbg (enable rx debugging)] ");
strcat(buffer, "[-rxdbge (enable rxevent debugging)] ");
nSmallVns = atoi(argv[++i]);
}
else
+ if (!strcmp(argv[i], "-abortthreshold")) {
+ abort_threshold = atoi(argv[++i]);
+ }
+ else
if (!strcmp(argv[i], "-k"))
stack = atoi(argv[++i]);
#if defined(AFS_SGI_ENV)
busy_threshold);
Sawbusy = 0;
}
- }
+ }
+ else
+ if (!strcmp(argv[i], "-nobusy"))
+ busyonrst=0;
#ifdef AFS_AIX32_ENV
else
if (!strcmp(argv[i], "-m")) {
static void NewParms(int initializing)
{
static struct stat sbuf;
- register afs_int64 i;
+ register afs_offs_t i;
register int fd;
char *parms;
char *argv[MAXPARMS];
return 0;
}
-#if 0
-static int AddrsEqual(cnt, addr1, addr2)
- int cnt;
- afs_int32 *addr1, *addr2;
-{
- register int i, j;
-
- for (i = 0; i < cnt; i++) {
- for (j = 0; j < cnt; j++) {
- if (addr1[i] == addr2[j]) break;
- }
- if (j == cnt) return 0;
- }
- return 1;
-}
-#endif
-
-afs_int32
-InitVL() {
+afs_int32 InitVL() {
int (*old)();
afs_int32 code;
afs_int32 cnt, i;
#ifdef AFS_PTHREAD_ENV
pthread_t parentPid, serverPid;
pthread_attr_t tattr;
- sigset_t nsigset;
#else /* AFS_PTHREAD_ENV */
PROCESS parentPid, serverPid;
#endif /* AFS_PTHREAD_ENV */
ViceLog(0, ("File server starting\n"));
#endif
+#if defined(AFS_PTHREAD_ENV)
+ /* initialize the pthread soft signal handler thread */
+ softsig_init();
+#endif
+
/* install signal handlers for controlling the fileserver process */
ResetCheckSignal(); /* set CheckSignal_Signal() sig handler */
ResetCheckDescriptors(); /* set CheckDescriptors_Signal() sig handler */
rx_extraPackets = rxpackets;
rx_extraQuota = 4; /* for outgoing prserver calls from R threads */
rx_SetBusyThreshold(busy_threshold, VBUSY);
- rx_SetCallAbortThreshold(10);
- rx_SetConnAbortThreshold(10);
+ rx_SetCallAbortThreshold(abort_threshold);
+ rx_SetConnAbortThreshold(abort_threshold);
stackSize = lwps * 4000;
if (stackSize < 32000)
stackSize = 32000;
#ifdef AFS_PTHREAD_ENV
assert(pthread_attr_init(&tattr) == 0);
assert(pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED) == 0);
- /* Block signals in this thread (and children), create a signal thread */
- sigfillset(&nsigset);
- assert(AFS_SET_SIGMASK(SIG_BLOCK, &nsigset, NULL) == 0);
- assert(pthread_create(&serverPid, &tattr, (void *)SignalLWP, NULL) == 0);
assert(pthread_create(&serverPid, &tattr, (void *)FiveMinuteCheckLWP, &fiveminutes) == 0);
assert(pthread_create(&serverPid, &tattr, (void *)HostCheckLWP, &fiveminutes) == 0);
FS_HostName, hoststr, FS_HostAddr_NBO, FS_HostAddr_HBO));
}
- /* Install handler to catch the shutdown signal */
- signal(SIGQUIT, ShutDown_Signal); /* bosserver assumes SIGQUIT shutdown */
+ /* Install handler to catch the shutdown signal;
+ * bosserver assumes SIGQUIT shutdown
+ */
+#if defined(AFS_PTHREAD_ENV)
+ softsig_signal(SIGQUIT, ShutDown_Signal);
+#else
+ signal(SIGQUIT, ShutDown_Signal);
+#endif
ViceLog(0,("File Server started %s",
afs_ctime(&tp.tv_sec, tbuffer, sizeof(tbuffer))));