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
63f64a8e
Commit
63f64a8e
authored
May 31, 2015
by
Vincent Castellano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding tgl.safe_exit()
parent
cbe442b7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
10 deletions
+25
-10
main.c
main.c
+8
-2
python-tg.c
python-tg.c
+17
-8
No files found.
main.c
View file @
63f64a8e
...
@@ -127,6 +127,7 @@ int ipv6_enabled;
...
@@ -127,6 +127,7 @@ int ipv6_enabled;
char
*
start_command
;
char
*
start_command
;
int
disable_link_preview
;
int
disable_link_preview
;
int
enable_json
;
int
enable_json
;
int
exit_code
;
struct
tgl_state
*
TLS
;
struct
tgl_state
*
TLS
;
...
@@ -834,6 +835,7 @@ void sig_term_handler (int signum __attribute__ ((unused))) {
...
@@ -834,6 +835,7 @@ void sig_term_handler (int signum __attribute__ ((unused))) {
}
}
void
do_halt
(
int
error
)
{
void
do_halt
(
int
error
)
{
int
retval
;
if
(
daemonize
)
{
if
(
daemonize
)
{
return
;
return
;
}
}
...
@@ -857,8 +859,12 @@ void do_halt (int error) {
...
@@ -857,8 +859,12 @@ void do_halt (int error) {
if
(
sfd
>
0
)
{
if
(
sfd
>
0
)
{
close
(
sfd
);
close
(
sfd
);
}
}
exit
(
error
?
EXIT_FAILURE
:
EXIT_SUCCESS
);
if
(
exit_code
)
retval
=
exit_code
;
else
retval
=
error
?
EXIT_FAILURE
:
EXIT_SUCCESS
;
exit
(
retval
);
}
}
int
main
(
int
argc
,
char
**
argv
)
{
int
main
(
int
argc
,
char
**
argv
)
{
...
...
python-tg.c
View file @
63f64a8e
...
@@ -1133,6 +1133,21 @@ PyObject* py_status_offline(PyObject *self, PyObject *args) { return push_py_fun
...
@@ -1133,6 +1133,21 @@ PyObject* py_status_offline(PyObject *self, PyObject *args) { return push_py_fun
PyObject
*
py_send_location
(
PyObject
*
self
,
PyObject
*
args
)
{
return
push_py_func
(
pq_send_location
,
args
);
}
PyObject
*
py_send_location
(
PyObject
*
self
,
PyObject
*
args
)
{
return
push_py_func
(
pq_send_location
,
args
);
}
PyObject
*
py_extf
(
PyObject
*
self
,
PyObject
*
args
)
{
return
push_py_func
(
pq_extf
,
args
);
}
PyObject
*
py_extf
(
PyObject
*
self
,
PyObject
*
args
)
{
return
push_py_func
(
pq_extf
,
args
);
}
extern
int
safe_quit
;
extern
int
exit_code
;
PyObject
*
py_safe_quit
(
PyObject
*
self
,
PyObject
*
args
)
{
int
exit_val
=
0
;
if
(
PyArg_ParseTuple
(
args
,
"|i"
,
&
exit_val
))
{
safe_quit
=
1
;
exit_code
=
exit_val
;
}
else
{
PyErr_Print
();
}
Py_RETURN_NONE
;
}
// Store callables for python functions
// Store callables for python functions
TGL_PYTHON_CALLBACK
(
"on_binlog_replay_end"
,
_py_binlog_end
);
TGL_PYTHON_CALLBACK
(
"on_binlog_replay_end"
,
_py_binlog_end
);
...
@@ -1197,6 +1212,8 @@ static PyMethodDef py_tgl_methods[] = {
...
@@ -1197,6 +1212,8 @@ static PyMethodDef py_tgl_methods[] = {
{
"set_on_user_update"
,
set_py_user_update
,
METH_VARARGS
,
""
},
{
"set_on_user_update"
,
set_py_user_update
,
METH_VARARGS
,
""
},
{
"set_on_chat_update"
,
set_py_chat_update
,
METH_VARARGS
,
""
},
{
"set_on_chat_update"
,
set_py_chat_update
,
METH_VARARGS
,
""
},
{
"set_on_loop"
,
set_py_on_loop
,
METH_VARARGS
,
""
},
{
"set_on_loop"
,
set_py_on_loop
,
METH_VARARGS
,
""
},
{
"safe_quit"
,
py_safe_quit
,
METH_VARARGS
,
""
},
{
"safe_exit"
,
py_safe_quit
,
METH_VARARGS
,
""
},
// Alias to safe_quit for naming consistancy in python.
{
NULL
,
NULL
,
0
,
NULL
}
{
NULL
,
NULL
,
0
,
NULL
}
};
};
...
@@ -1236,14 +1253,6 @@ MOD_INIT(tgl)
...
@@ -1236,14 +1253,6 @@ MOD_INIT(tgl)
return
MOD_SUCCESS_VAL
(
m
);
return
MOD_SUCCESS_VAL
(
m
);
}
}
/*
extern int safe_quit;
static int safe_quit_from_py() {
Py_Finalize();
safe_quit = 1;
return 1;
}
*/
void
py_init
(
const
char
*
file
)
{
void
py_init
(
const
char
*
file
)
{
if
(
!
file
)
{
return
;
}
if
(
!
file
)
{
return
;
}
...
...
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