2010-08-31 17:47:57 +08:00
|
|
|
// Copyright (c) 2004-2009 Sergey Lyubka
|
|
|
|
//
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
// of this software and associated documentation files (the "Software"), to deal
|
|
|
|
// in the Software without restriction, including without limitation the rights
|
|
|
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
// copies of the Software, and to permit persons to whom the Software is
|
|
|
|
// furnished to do so, subject to the following conditions:
|
|
|
|
//
|
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
|
|
// all copies or substantial portions of the Software.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
// THE SOFTWARE.
|
2010-05-04 04:46:42 +08:00
|
|
|
|
|
|
|
#if defined(_WIN32)
|
2010-08-31 17:47:57 +08:00
|
|
|
#define _CRT_SECURE_NO_WARNINGS // Disable deprecation warning in VS2005
|
|
|
|
#else
|
|
|
|
#define _XOPEN_SOURCE 600 // For PATH_MAX on linux
|
|
|
|
#endif
|
2010-05-04 04:46:42 +08:00
|
|
|
|
2010-08-30 19:54:46 +08:00
|
|
|
#include <sys/stat.h>
|
2010-05-04 04:46:42 +08:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <signal.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <limits.h>
|
2010-06-25 23:23:17 +08:00
|
|
|
#include <stddef.h>
|
2010-09-07 04:42:05 +08:00
|
|
|
#include <stdarg.h>
|
2010-05-04 04:46:42 +08:00
|
|
|
|
|
|
|
#include "mongoose.h"
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
#include <windows.h>
|
|
|
|
#include <winsvc.h>
|
2010-08-31 07:12:16 +08:00
|
|
|
#define PATH_MAX MAX_PATH
|
|
|
|
#define S_ISDIR(x) ((x) & _S_IFDIR)
|
2010-09-07 04:42:05 +08:00
|
|
|
#define DIRSEP '\\'
|
|
|
|
#define snprintf _snprintf
|
|
|
|
#define vsnprintf _vsnprintf
|
|
|
|
#define sleep(x) Sleep((x) * 1000)
|
2010-09-07 18:00:10 +08:00
|
|
|
#define WINCDECL __cdecl
|
2010-05-04 04:46:42 +08:00
|
|
|
#else
|
|
|
|
#include <sys/wait.h>
|
2010-09-07 04:42:05 +08:00
|
|
|
#include <unistd.h>
|
2010-05-04 04:46:42 +08:00
|
|
|
#define DIRSEP '/'
|
2010-09-07 18:00:10 +08:00
|
|
|
#define WINCDECL
|
2010-09-07 04:42:05 +08:00
|
|
|
#endif // _WIN32
|
|
|
|
|
|
|
|
#define MAX_OPTIONS 40
|
2010-05-04 04:46:42 +08:00
|
|
|
|
2010-09-07 04:42:05 +08:00
|
|
|
static int exit_flag;
|
|
|
|
static char *options[MAX_OPTIONS];
|
|
|
|
static char server_name[40];
|
|
|
|
static struct mg_context *ctx;
|
2010-05-04 04:46:42 +08:00
|
|
|
|
|
|
|
#if !defined(CONFIG_FILE)
|
2010-08-31 15:01:14 +08:00
|
|
|
#define CONFIG_FILE "mongoose.conf"
|
2010-05-04 04:46:42 +08:00
|
|
|
#endif /* !CONFIG_FILE */
|
|
|
|
|
2010-09-07 18:00:10 +08:00
|
|
|
static void WINCDECL signal_handler(int sig_num) {
|
2010-05-04 04:46:42 +08:00
|
|
|
#if !defined(_WIN32)
|
2010-08-30 05:30:49 +08:00
|
|
|
if (sig_num == SIGCHLD) {
|
|
|
|
do {
|
|
|
|
} while (waitpid(-1, &sig_num, WNOHANG) > 0);
|
|
|
|
} else
|
2010-05-04 04:46:42 +08:00
|
|
|
#endif /* !_WIN32 */
|
2010-08-30 05:30:49 +08:00
|
|
|
{
|
|
|
|
exit_flag = sig_num;
|
|
|
|
}
|
2010-05-04 04:46:42 +08:00
|
|
|
}
|
|
|
|
|
2010-09-07 04:42:05 +08:00
|
|
|
static void die(const char *fmt, ...) {
|
|
|
|
va_list ap;
|
|
|
|
char msg[200];
|
|
|
|
|
|
|
|
va_start(ap, fmt);
|
|
|
|
vsnprintf(msg, sizeof(msg), fmt, ap);
|
|
|
|
va_end(ap);
|
|
|
|
|
|
|
|
#if defined(_WIN32)
|
|
|
|
MessageBox(NULL, msg, "Error", MB_OK);
|
|
|
|
#else
|
|
|
|
fprintf(stderr, "%s\n", msg);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
2010-05-04 04:46:42 +08:00
|
|
|
/*
|
|
|
|
* Edit the passwords file.
|
|
|
|
*/
|
2010-08-30 05:30:49 +08:00
|
|
|
static int mg_edit_passwords(const char *fname, const char *domain,
|
|
|
|
const char *user, const char *pass) {
|
|
|
|
struct mg_context *ctx;
|
|
|
|
const char *options[] = {"authentication_domain", NULL, NULL};
|
|
|
|
int success;
|
|
|
|
|
|
|
|
options[1] = domain;
|
|
|
|
ctx = mg_start(NULL, options);
|
|
|
|
success = mg_modify_passwords_file(ctx, fname, user, pass);
|
|
|
|
mg_stop(ctx);
|
|
|
|
|
|
|
|
return success;
|
2010-05-04 04:46:42 +08:00
|
|
|
}
|
|
|
|
|
2010-08-30 05:30:49 +08:00
|
|
|
static void show_usage_and_exit(void) {
|
|
|
|
const char **names;
|
2010-08-30 20:10:10 +08:00
|
|
|
int i;
|
2010-08-30 05:30:49 +08:00
|
|
|
|
|
|
|
fprintf(stderr, "Mongoose version %s (c) Sergey Lyubka\n", mg_version());
|
|
|
|
fprintf(stderr, "Usage:\n");
|
|
|
|
fprintf(stderr, " mongoose -A <htpasswd_file> <realm> <user> <passwd>\n");
|
|
|
|
fprintf(stderr, " mongoose <config_file>\n");
|
|
|
|
fprintf(stderr, " mongoose [-option value ...]\n");
|
2010-08-30 20:10:10 +08:00
|
|
|
fprintf(stderr, "OPTIONS:\n");
|
2010-08-30 05:30:49 +08:00
|
|
|
|
|
|
|
names = mg_get_valid_option_names();
|
2010-08-31 15:01:14 +08:00
|
|
|
for (i = 0; names[i] != NULL; i += 3) {
|
|
|
|
fprintf(stderr, " -%s %s (default: \"%s\")\n",
|
|
|
|
names[i], names[i + 1], names[i + 2] == NULL ? "" : names[i + 2]);
|
2010-08-30 05:30:49 +08:00
|
|
|
}
|
|
|
|
fprintf(stderr, "See http://code.google.com/p/mongoose/wiki/MongooseManual"
|
|
|
|
" for more details.\n");
|
2010-08-30 20:10:10 +08:00
|
|
|
fprintf(stderr, "Example:\n mongoose -s cert.pem -p 80,443s -d no\n");
|
2010-08-30 05:30:49 +08:00
|
|
|
exit(EXIT_FAILURE);
|
2010-06-25 23:23:17 +08:00
|
|
|
}
|
|
|
|
|
2010-08-30 19:54:46 +08:00
|
|
|
static void verify_document_root(const char *root) {
|
|
|
|
const char *p, *path;
|
|
|
|
char buf[PATH_MAX];
|
|
|
|
struct stat st;
|
|
|
|
|
|
|
|
path = root;
|
|
|
|
if ((p = strchr(root, ',')) != NULL && (size_t) (p - root) < sizeof(buf)) {
|
|
|
|
strncpy(buf, root, p - root);
|
|
|
|
path = buf;
|
|
|
|
}
|
|
|
|
|
2010-08-30 21:59:21 +08:00
|
|
|
if (stat(path, &st) != 0 || !S_ISDIR(st.st_mode)) {
|
2010-09-07 04:42:05 +08:00
|
|
|
die("Invalid root directory: \"%s\"", root);
|
2010-08-30 19:54:46 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-30 05:30:49 +08:00
|
|
|
static char *sdup(const char *str) {
|
|
|
|
char *p;
|
|
|
|
if ((p = malloc(strlen(str) + 1)) != NULL) {
|
|
|
|
strcpy(p, str);
|
|
|
|
}
|
|
|
|
return p;
|
|
|
|
}
|
2010-06-25 23:23:17 +08:00
|
|
|
|
2010-08-30 05:30:49 +08:00
|
|
|
static void set_option(char **options, const char *name, const char *value) {
|
|
|
|
int i;
|
|
|
|
|
2010-08-30 21:59:21 +08:00
|
|
|
if (!strcmp(name, "document_root") || !(strcmp(name, "r"))) {
|
2010-08-30 19:54:46 +08:00
|
|
|
verify_document_root(value);
|
|
|
|
}
|
|
|
|
|
2010-08-30 05:30:49 +08:00
|
|
|
for (i = 0; i < MAX_OPTIONS - 3; i++) {
|
|
|
|
if (options[i] == NULL) {
|
|
|
|
options[i] = sdup(name);
|
|
|
|
options[i + 1] = sdup(value);
|
|
|
|
options[i + 2] = NULL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i == MAX_OPTIONS - 3) {
|
2010-09-07 04:42:05 +08:00
|
|
|
die("%s", "Too many options specified");
|
2010-08-30 05:30:49 +08:00
|
|
|
}
|
2010-06-25 23:23:17 +08:00
|
|
|
}
|
|
|
|
|
2010-08-30 05:30:49 +08:00
|
|
|
static void process_command_line_arguments(char *argv[], char **options) {
|
2010-08-30 21:59:21 +08:00
|
|
|
const char *config_file = NULL;
|
2010-09-07 18:00:10 +08:00
|
|
|
char line[512], opt[512], val[512], path[PATH_MAX], *p;
|
2010-08-30 21:59:21 +08:00
|
|
|
FILE *fp = NULL;
|
2010-08-31 15:01:14 +08:00
|
|
|
struct stat st;
|
2010-08-30 05:30:49 +08:00
|
|
|
size_t i, line_no = 0;
|
|
|
|
|
2010-08-30 21:59:21 +08:00
|
|
|
/* Should we use a config file ? */
|
|
|
|
if (argv[1] != NULL && argv[2] == NULL) {
|
|
|
|
config_file = argv[1];
|
2010-09-08 14:56:15 +08:00
|
|
|
} else if (argv[1] == NULL && (p = strrchr(argv[0], DIRSEP)) == NULL) {
|
2010-09-03 11:01:26 +08:00
|
|
|
// No command line flags specified. Look where binary lives
|
2010-09-07 18:00:10 +08:00
|
|
|
config_file = CONFIG_FILE;
|
|
|
|
} else if (argv[1] == NULL) {
|
|
|
|
snprintf(path, sizeof(path), "%.*s%c%s",
|
|
|
|
(int) (p - argv[0]), argv[0], DIRSEP, CONFIG_FILE);
|
2010-08-31 15:01:14 +08:00
|
|
|
if (stat(path, &st) == 0) {
|
|
|
|
config_file = path;
|
|
|
|
}
|
2010-08-30 05:30:49 +08:00
|
|
|
}
|
|
|
|
/* If config file was set in command line and open failed, exit */
|
2010-08-30 21:59:21 +08:00
|
|
|
if (config_file != NULL && (fp = fopen(config_file, "r")) == NULL) {
|
2010-09-07 04:42:05 +08:00
|
|
|
die("Cannot open config file %s: %s", config_file, strerror(errno));
|
2010-08-30 05:30:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (fp != NULL) {
|
2010-08-30 21:59:21 +08:00
|
|
|
fprintf(stderr, "Loading config file %s\n", config_file);
|
2010-08-30 05:30:49 +08:00
|
|
|
|
|
|
|
/* Loop over the lines in config file */
|
|
|
|
while (fgets(line, sizeof(line), fp) != NULL) {
|
|
|
|
|
|
|
|
line_no++;
|
|
|
|
|
|
|
|
/* Ignore empty lines and comments */
|
|
|
|
if (line[0] == '#' || line[0] == '\n')
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (sscanf(line, "%s %[^\r\n#]", opt, val) != 2) {
|
2010-09-07 04:42:05 +08:00
|
|
|
die("%s: line %d is invalid", config_file, (int) line_no);
|
2010-08-30 05:30:49 +08:00
|
|
|
}
|
|
|
|
set_option(options, opt, val);
|
|
|
|
}
|
|
|
|
|
|
|
|
(void) fclose(fp);
|
|
|
|
} else {
|
2010-08-30 21:59:21 +08:00
|
|
|
for (i = 1; argv[i] != NULL; i += 2) {
|
2010-09-07 04:42:05 +08:00
|
|
|
if (argv[i][0] != '-' || argv[i + 1] == NULL) {
|
2010-08-30 21:59:21 +08:00
|
|
|
show_usage_and_exit();
|
|
|
|
}
|
2010-08-30 05:30:49 +08:00
|
|
|
set_option(options, &argv[i][1], argv[i + 1]);
|
2010-08-30 21:59:21 +08:00
|
|
|
}
|
2010-08-30 05:30:49 +08:00
|
|
|
}
|
2010-05-04 04:46:42 +08:00
|
|
|
}
|
|
|
|
|
2010-09-07 04:42:05 +08:00
|
|
|
static void start_mongoose(int argc, char *argv[]) {
|
2010-08-30 05:30:49 +08:00
|
|
|
int i;
|
|
|
|
|
2010-09-07 04:42:05 +08:00
|
|
|
snprintf(server_name, sizeof(server_name),
|
|
|
|
"Mongoose %s web server", mg_version());
|
|
|
|
|
2010-08-30 05:30:49 +08:00
|
|
|
/* Edit passwords file if -A option is specified */
|
|
|
|
if (argc > 1 && argv[1][0] == '-' && argv[1][1] == 'A') {
|
|
|
|
if (argc != 6) {
|
|
|
|
show_usage_and_exit();
|
|
|
|
}
|
|
|
|
exit(mg_edit_passwords(argv[2], argv[3], argv[4], argv[5]) ?
|
|
|
|
EXIT_SUCCESS : EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Show usage if -h or --help options are specified */
|
|
|
|
if (argc == 2 && (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help"))) {
|
|
|
|
show_usage_and_exit();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Update config based on command line arguments */
|
|
|
|
process_command_line_arguments(argv, options);
|
|
|
|
|
|
|
|
/* Setup signal handler: quit on Ctrl-C */
|
2010-05-04 04:46:42 +08:00
|
|
|
#ifndef _WIN32
|
2010-08-30 05:30:49 +08:00
|
|
|
signal(SIGCHLD, signal_handler);
|
2010-05-04 04:46:42 +08:00
|
|
|
#endif /* _WIN32 */
|
2010-08-30 05:30:49 +08:00
|
|
|
signal(SIGTERM, signal_handler);
|
|
|
|
signal(SIGINT, signal_handler);
|
|
|
|
|
|
|
|
/* Start Mongoose */
|
|
|
|
ctx = mg_start(NULL, (const char **) options);
|
|
|
|
for (i = 0; options[i] != NULL; i++) {
|
|
|
|
free(options[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ctx == NULL) {
|
2010-09-07 04:42:05 +08:00
|
|
|
die("%s", "Failed to start Mongoose. Maybe some options are "
|
|
|
|
"assigned bad values?\nTry to run with '-e error_log.txt' "
|
|
|
|
"and check error_log.txt for more information.");
|
2010-08-30 05:30:49 +08:00
|
|
|
}
|
2010-09-07 04:42:05 +08:00
|
|
|
}
|
2010-08-30 05:30:49 +08:00
|
|
|
|
2010-09-07 04:42:05 +08:00
|
|
|
#ifdef _WIN32
|
|
|
|
static SERVICE_STATUS ss;
|
|
|
|
static SERVICE_STATUS_HANDLE hStatus;
|
2010-08-30 05:30:49 +08:00
|
|
|
|
2010-09-07 04:42:05 +08:00
|
|
|
static void WINAPI ControlHandler(DWORD code) {
|
|
|
|
if (code == SERVICE_CONTROL_STOP || code == SERVICE_CONTROL_SHUTDOWN) {
|
|
|
|
ss.dwWin32ExitCode = 0;
|
|
|
|
ss.dwCurrentState = SERVICE_STOPPED;
|
|
|
|
}
|
|
|
|
SetServiceStatus(hStatus, &ss);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void WINAPI ServiceMain(void) {
|
|
|
|
ss.dwServiceType = SERVICE_WIN32;
|
|
|
|
ss.dwCurrentState = SERVICE_RUNNING;
|
|
|
|
ss.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN;
|
|
|
|
|
|
|
|
hStatus = RegisterServiceCtrlHandler(server_name, ControlHandler);
|
|
|
|
SetServiceStatus(hStatus, &ss);
|
|
|
|
|
|
|
|
//Sleep(3000);
|
|
|
|
while (ss.dwCurrentState == SERVICE_RUNNING) {
|
|
|
|
Sleep(1000);
|
|
|
|
}
|
|
|
|
mg_stop(ctx);
|
|
|
|
|
|
|
|
ss.dwCurrentState = SERVICE_STOPPED;
|
|
|
|
ss.dwWin32ExitCode = (DWORD) -1;
|
|
|
|
SetServiceStatus(hStatus, &ss);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void try_to_run_as_nt_service(void) {
|
|
|
|
static SERVICE_TABLE_ENTRY service_table[] = {
|
|
|
|
{server_name, (LPSERVICE_MAIN_FUNCTION) ServiceMain},
|
|
|
|
{NULL, NULL}
|
|
|
|
};
|
|
|
|
|
|
|
|
if (StartServiceCtrlDispatcher(service_table)) {
|
|
|
|
exit(EXIT_SUCCESS);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#define ID_TRAYICON 100
|
|
|
|
#define ID_QUIT 101
|
|
|
|
static NOTIFYICONDATA ni;
|
|
|
|
|
|
|
|
static LRESULT CALLBACK WindowProc(HWND hWnd, UINT msg, WPARAM wParam,
|
|
|
|
LPARAM lParam) {
|
|
|
|
POINT pt;
|
|
|
|
HMENU hMenu;
|
|
|
|
|
|
|
|
switch (msg) {
|
|
|
|
|
|
|
|
case WM_COMMAND:
|
|
|
|
switch (LOWORD(wParam)) {
|
|
|
|
case ID_QUIT:
|
|
|
|
exit(EXIT_SUCCESS);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_USER:
|
|
|
|
switch (lParam) {
|
|
|
|
case WM_RBUTTONUP:
|
|
|
|
case WM_LBUTTONUP:
|
|
|
|
case WM_LBUTTONDBLCLK:
|
|
|
|
hMenu = CreatePopupMenu();
|
|
|
|
AppendMenu(hMenu, 0, ID_QUIT, "Exit");
|
|
|
|
GetCursorPos(&pt);
|
|
|
|
TrackPopupMenu(hMenu, 0, pt.x, pt.y, 0, hWnd, NULL);
|
|
|
|
DestroyMenu(hMenu);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return DefWindowProc(hWnd, msg, wParam, lParam);
|
|
|
|
}
|
|
|
|
|
|
|
|
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR cmdline, int show) {
|
|
|
|
WNDCLASS cls;
|
|
|
|
HWND hWnd;
|
|
|
|
MSG msg;
|
|
|
|
|
|
|
|
// Win32 runtime must prepare __argc and __argv for us
|
|
|
|
start_mongoose(__argc, __argv);
|
|
|
|
try_to_run_as_nt_service();
|
|
|
|
|
|
|
|
memset(&cls, 0, sizeof(cls));
|
|
|
|
cls.lpfnWndProc = (WNDPROC) WindowProc;
|
|
|
|
cls.hIcon = LoadIcon(NULL, IDI_APPLICATION);
|
|
|
|
cls.lpszClassName = server_name;
|
|
|
|
|
|
|
|
RegisterClass(&cls);
|
|
|
|
hWnd = CreateWindow(cls.lpszClassName, server_name, WS_OVERLAPPEDWINDOW,
|
|
|
|
0, 0, 0, 0, NULL, NULL, NULL, NULL);
|
|
|
|
ShowWindow(hWnd, SW_HIDE);
|
|
|
|
|
|
|
|
ni.cbSize = sizeof(ni);
|
|
|
|
ni.uID = ID_TRAYICON;
|
|
|
|
ni.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
|
|
|
|
ni.hIcon = LoadIcon(NULL, IDI_APPLICATION);
|
|
|
|
ni.hWnd = hWnd;
|
|
|
|
snprintf(ni.szTip, sizeof(ni.szTip), "%s", server_name);
|
|
|
|
ni.uCallbackMessage = WM_USER;
|
|
|
|
Shell_NotifyIcon(NIM_ADD, &ni);
|
|
|
|
|
|
|
|
while (GetMessage(&msg, hWnd, 0, 0)) {
|
|
|
|
TranslateMessage(&msg);
|
|
|
|
DispatchMessage(&msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* _WIN32 */
|
|
|
|
|
2010-09-08 04:11:43 +08:00
|
|
|
int WINCDECL main(int argc, char *argv[]) {
|
2010-09-07 04:42:05 +08:00
|
|
|
start_mongoose(argc, argv);
|
|
|
|
printf("%s started on port(s) %s with web root [%s]\n",
|
|
|
|
server_name, mg_get_option(ctx, "listening_ports"),
|
|
|
|
mg_get_option(ctx, "document_root"));
|
2010-08-30 05:30:49 +08:00
|
|
|
while (exit_flag == 0) {
|
|
|
|
sleep(1);
|
|
|
|
}
|
|
|
|
printf("Exiting on signal %d, waiting for all threads to finish...",
|
|
|
|
exit_flag);
|
|
|
|
fflush(stdout);
|
|
|
|
mg_stop(ctx);
|
|
|
|
printf("%s", " done.\n");
|
|
|
|
|
|
|
|
return EXIT_SUCCESS;
|
2010-05-04 04:46:42 +08:00
|
|
|
}
|