fix multi bugs

- wrong function return type in Python binding
 - wrong argument number in logger.h
 - add unlimit value check for stack size limit
This commit is contained in:
virusdefender 2017-10-14 21:05:49 +08:00
parent fa2ea94eb6
commit 64eeead91e
3 changed files with 8 additions and 6 deletions

View File

@ -100,7 +100,7 @@ static PyObject *judger_run(PyObject *self, PyObject *args, PyObject *kwargs) {
}
void *handler = dlopen("/usr/lib/judger/libjudger.so", RTLD_LAZY);
int (*judger_run)(struct config *, struct result *);
void (*judger_run)(struct config *, struct result *);
if (!handler) {
RaiseValueError("dlopen error")

View File

@ -39,10 +39,12 @@ void close_file(FILE *fp, ...) {
int child_process(FILE *log_fp, struct config *_config) {
FILE *input_file = NULL, *output_file = NULL, *error_file = NULL;
struct rlimit max_stack;
max_stack.rlim_cur = max_stack.rlim_max = (rlim_t) (_config->max_stack);
if (setrlimit(RLIMIT_STACK, &max_stack) != 0) {
CHILD_ERROR_EXIT(SETRLIMIT_FAILED);
if (_config->max_stack != UNLIMITED) {
struct rlimit max_stack;
max_stack.rlim_cur = max_stack.rlim_max = (rlim_t) (_config->max_stack);
if (setrlimit(RLIMIT_STACK, &max_stack) != 0) {
CHILD_ERROR_EXIT(SETRLIMIT_FAILED);
}
}
// set memory limit

View File

@ -19,7 +19,7 @@ void log_write(int level, const char *source_filename, const int line_number, co
#define LOG_DEBUG(log_fp, x...)
#endif
#define LOG_INFO(log_fp, x...) log_write(LOG_LEVEL_INFO, __FILE__ __LINE__, log_fp, ##x)
#define LOG_INFO(log_fp, x...) log_write(LOG_LEVEL_INFO, __FILE__, __LINE__, log_fp, ##x)
#define LOG_WARNING(log_fp, x...) log_write(LOG_LEVEL_WARNING, __FILE__, __LINE__, log_fp, ##x)
#define LOG_FATAL(log_fp, x...) log_write(LOG_LEVEL_FATAL, __FILE__, __LINE__, log_fp, ##x)