Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
tg
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
tg
Commits
fde3182b
Commit
fde3182b
authored
Dec 22, 2014
by
George Fleury
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid loop break when daemonize option is on, now daemonize runs forever until sigkill or sigterm
parent
2409907c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
4 deletions
+18
-4
interface.c
interface.c
+10
-0
loop.c
loop.c
+3
-2
main.c
main.c
+5
-2
No files found.
interface.c
View file @
fde3182b
...
@@ -104,8 +104,12 @@ extern int usfd;
...
@@ -104,8 +104,12 @@ extern int usfd;
extern
int
sfd
;
extern
int
sfd
;
extern
int
use_ids
;
extern
int
use_ids
;
extern
int
daemonize
;
extern
struct
tgl_state
*
TLS
;
extern
struct
tgl_state
*
TLS
;
void
event_incoming
(
struct
bufferevent
*
bev
,
short
what
,
void
*
_arg
);
int
is_same_word
(
const
char
*
s
,
size_t
l
,
const
char
*
word
)
{
int
is_same_word
(
const
char
*
s
,
size_t
l
,
const
char
*
word
)
{
return
s
&&
word
&&
strlen
(
word
)
==
l
&&
!
memcmp
(
s
,
word
,
l
);
return
s
&&
word
&&
strlen
(
word
)
==
l
&&
!
memcmp
(
s
,
word
,
l
);
}
}
...
@@ -909,10 +913,16 @@ void do_status_offline (int arg_num, struct arg args[], struct in_ev *ev) {
...
@@ -909,10 +913,16 @@ void do_status_offline (int arg_num, struct arg args[], struct in_ev *ev) {
}
}
void
do_quit
(
int
arg_num
,
struct
arg
args
[],
struct
in_ev
*
ev
)
{
void
do_quit
(
int
arg_num
,
struct
arg
args
[],
struct
in_ev
*
ev
)
{
if
(
daemonize
)
event_incoming
(
ev
->
bev
,
BEV_EVENT_EOF
,
ev
);
//bufferevent_free(ev->bev);
do_halt
(
0
);
do_halt
(
0
);
}
}
void
do_safe_quit
(
int
arg_num
,
struct
arg
args
[],
struct
in_ev
*
ev
)
{
void
do_safe_quit
(
int
arg_num
,
struct
arg
args
[],
struct
in_ev
*
ev
)
{
if
(
daemonize
)
event_incoming
(
ev
->
bev
,
BEV_EVENT_EOF
,
ev
);
//bufferevent_free(ev->bev);
safe_quit
=
1
;
safe_quit
=
1
;
}
}
...
...
loop.c
View file @
fde3182b
...
@@ -192,6 +192,7 @@ void net_loop (int flags, int (*is_end)(void)) {
...
@@ -192,6 +192,7 @@ void net_loop (int flags, int (*is_end)(void)) {
if
(
safe_quit
&&
!
TLS
->
active_queries
)
{
if
(
safe_quit
&&
!
TLS
->
active_queries
)
{
printf
(
"All done. Exit
\n
"
);
printf
(
"All done. Exit
\n
"
);
do_halt
(
0
);
do_halt
(
0
);
safe_quit
=
0
;
}
}
if
(
sigterm_cnt
>
0
)
{
if
(
sigterm_cnt
>
0
)
{
do_halt
(
0
);
do_halt
(
0
);
...
@@ -682,7 +683,7 @@ static void read_incoming (struct bufferevent *bev, void *_arg) {
...
@@ -682,7 +683,7 @@ static void read_incoming (struct bufferevent *bev, void *_arg) {
}
}
}
}
static
void
event_incoming
(
struct
bufferevent
*
bev
,
short
what
,
void
*
_arg
)
{
void
event_incoming
(
struct
bufferevent
*
bev
,
short
what
,
void
*
_arg
)
{
struct
in_ev
*
ev
=
_arg
;
struct
in_ev
*
ev
=
_arg
;
if
(
what
&
(
BEV_EVENT_EOF
|
BEV_EVENT_ERROR
))
{
if
(
what
&
(
BEV_EVENT_EOF
|
BEV_EVENT_ERROR
))
{
vlogprintf
(
E_WARNING
,
"Closing incoming connection
\n
"
);
vlogprintf
(
E_WARNING
,
"Closing incoming connection
\n
"
);
...
@@ -701,7 +702,7 @@ static void accept_incoming (evutil_socket_t efd, short what, void *arg) {
...
@@ -701,7 +702,7 @@ static void accept_incoming (evutil_socket_t efd, short what, void *arg) {
int
fd
=
accept
(
efd
,
(
struct
sockaddr
*
)
&
cli_addr
,
&
clilen
);
int
fd
=
accept
(
efd
,
(
struct
sockaddr
*
)
&
cli_addr
,
&
clilen
);
assert
(
fd
>=
0
);
assert
(
fd
>=
0
);
struct
bufferevent
*
bev
=
bufferevent_socket_new
(
TLS
->
ev_base
,
fd
,
0
);
struct
bufferevent
*
bev
=
bufferevent_socket_new
(
TLS
->
ev_base
,
fd
,
BEV_OPT_CLOSE_ON_FREE
);
struct
in_ev
*
e
=
malloc
(
sizeof
(
*
e
));
struct
in_ev
*
e
=
malloc
(
sizeof
(
*
e
));
e
->
bev
=
bev
;
e
->
bev
=
bev
;
e
->
refcnt
=
1
;
e
->
refcnt
=
1
;
...
...
main.c
View file @
fde3182b
...
@@ -491,7 +491,7 @@ int disable_auto_accept;
...
@@ -491,7 +491,7 @@ int disable_auto_accept;
int
wait_dialog_list
;
int
wait_dialog_list
;
char
*
logname
;
char
*
logname
;
int
daemonize
;
int
daemonize
=
0
;
void
reopen_logs
(
void
)
{
void
reopen_logs
(
void
)
{
...
@@ -741,11 +741,14 @@ void sig_term_handler (int signum __attribute__ ((unused))) {
...
@@ -741,11 +741,14 @@ void sig_term_handler (int signum __attribute__ ((unused))) {
}
}
void
do_halt
(
int
error
)
{
void
do_halt
(
int
error
)
{
if
(
daemonize
)
return
;
if
(
!
readline_disabled
)
{
if
(
!
readline_disabled
)
{
rl_free_line_state
();
rl_free_line_state
();
rl_cleanup_after_signal
();
rl_cleanup_after_signal
();
}
}
if
(
write
(
1
,
"halt
\n
"
,
5
)
<
0
)
{
if
(
write
(
1
,
"halt
\n
"
,
5
)
<
0
)
{
// Sad thing
// Sad thing
}
}
...
...
Write
Preview
Markdown
is supported
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