Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Nadezhda Ivanova
OpenLDAP
Commits
6db166f0
Commit
6db166f0
authored
Mar 26, 2003
by
Kurt Zeilenga
Browse files
Slurpd fixes from HEAD
parent
27e02bc8
Changes
3
Hide whitespace changes
Inline
Side-by-side
servers/slurpd/fm.c
View file @
6db166f0
...
...
@@ -26,6 +26,7 @@
#include
<ac/stdlib.h>
#include
<ac/string.h>
#include
<ac/signal.h>
#include
<ac/socket.h>
#include
"slurp.h"
#include
"globals.h"
...
...
@@ -52,21 +53,19 @@ fm(
)
{
int
rc
;
int
i
;
fd_set
readfds
;
/* Set up our signal handlers:
* SIG{TERM,INT,HUP} causes a shutdown
* LDAP_SIGUSR1 - does nothing, used to wake up sleeping threads.
* LDAP_SIGUSR2 - causes a shutdown
*/
(
void
)
SIGNAL
(
LDAP_SIGUSR1
,
do_nothing
);
(
void
)
SIGNAL
(
LDAP_SIGUSR2
,
slurp_set_shutdown
);
(
void
)
SIGNAL
(
SIGTERM
,
slurp_set_shutdown
);
(
void
)
SIGNAL
(
SIGINT
,
slurp_set_shutdown
);
#ifdef SIGHUP
(
void
)
SIGNAL
(
SIGHUP
,
slurp_set_shutdown
);
#endif
#ifdef
SIGBREAK
(
void
)
SIGNAL
(
SIGBREAK
,
slurp_set_shutdown
);
#if
def
ined(
SIGBREAK
) && defined(HAVE_NT_SERVICE_MANAGER)
(
void
)
SIGNAL
(
SIGBREAK
,
do_nothing
);
#endif
if
(
sglob
->
one_shot_mode
)
{
...
...
@@ -89,6 +88,7 @@ fm(
populate_queue
(
sglob
->
slurpd_replogfile
);
}
FD_ZERO
(
&
readfds
);
while
(
!
sglob
->
slurpd_shutdown
)
{
if
(
file_nonempty
(
sglob
->
slapd_replogfile
))
{
...
...
@@ -117,7 +117,13 @@ fm(
}
}
}
else
{
ldap_pvt_thread_sleep
(
sglob
->
no_work_interval
);
struct
timeval
tv
;
FD_SET
(
sglob
->
wake_sds
[
0
],
&
readfds
);
tv
.
tv_sec
=
sglob
->
no_work_interval
;
tv
.
tv_usec
=
0
;
rc
=
select
(
sglob
->
wake_sds
[
0
]
+
1
,
&
readfds
,
NULL
,
NULL
,
&
tv
);
}
/* Garbage-collect queue */
...
...
@@ -143,6 +149,12 @@ fm(
}
}
}
sglob
->
rq
->
rq_lock
(
sglob
->
rq
);
/* lock queue */
ldap_pvt_thread_cond_broadcast
(
&
(
sglob
->
rq
->
rq_more
)
);
/* wake repl threads */
for
(
i
=
0
;
i
<
sglob
->
num_replicas
;
i
++
)
{
(
sglob
->
replicas
[
i
])
->
ri_wake
(
sglob
->
replicas
[
i
]);
}
sglob
->
rq
->
rq_unlock
(
sglob
->
rq
);
/* unlock queue */
#ifdef NEW_LOGGING
LDAP_LOG
(
SLURPD
,
RESULTS
,
"fm: exiting
\n
"
,
0
,
0
,
0
);
#else
...
...
@@ -160,20 +172,9 @@ fm(
RETSIGTYPE
slurp_set_shutdown
(
int
sig
)
{
int
i
;
#if HAVE_NT_SERVICE_MANAGER && SIGBREAK
if
(
sig
==
SIGBREAK
)
return
do_nothing
(
sig
);
#endif
sglob
->
slurpd_shutdown
=
1
;
/* set flag */
ldap_pvt_thread_kill
(
sglob
->
fm_tid
,
LDAP_SIGUSR1
);
/* wake up file mgr */
sglob
->
rq
->
rq_lock
(
sglob
->
rq
);
/* lock queue */
ldap_pvt_thread_cond_broadcast
(
&
(
sglob
->
rq
->
rq_more
)
);
/* wake repl threads */
for
(
i
=
0
;
i
<
sglob
->
num_replicas
;
i
++
)
{
(
sglob
->
replicas
[
i
])
->
ri_wake
(
sglob
->
replicas
[
i
]);
}
sglob
->
rq
->
rq_unlock
(
sglob
->
rq
);
/* unlock queue */
tcp_write
(
sglob
->
wake_sds
[
1
],
"0"
,
1
);
/* wake up file mgr */
(
void
)
SIGNAL_REINSTALL
(
sig
,
slurp_set_shutdown
);
/* reinstall handlers */
}
...
...
servers/slurpd/globals.h
View file @
6db166f0
...
...
@@ -29,6 +29,8 @@ LDAP_BEGIN_DECL
typedef
struct
globals
{
/* Thread ID for file manager thread */
ldap_pvt_thread_t
fm_tid
;
/* pipe/socket used to wake manager from signal handler */
int
wake_sds
[
2
];
/* The name of the slapd config file (which is also our config file) */
char
*
slapd_configfile
;
/* How long the master slurpd sleeps when there's no work to do */
...
...
servers/slurpd/main.c
View file @
6db166f0
...
...
@@ -185,6 +185,12 @@ int main( int argc, char **argv )
lutil_detach
(
0
,
0
);
#endif
if
(
(
rc
=
lutil_pair
(
sglob
->
wake_sds
))
<
0
)
{
SERVICE_EXIT
(
ERROR_SERVICE_SPECIFIC_ERROR
,
16
);
rc
=
1
;
goto
stop
;
}
#ifdef HAVE_NT_EVENT_LOG
if
(
is_NT_Service
)
lutil_LogStartedEvent
(
sglob
->
serverName
,
ldap_debug
,
sglob
->
slapd_configfile
,
"n/a"
);
#endif
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment