Switch to unified view

a/src/common/rclinit.cpp b/src/common/rclinit.cpp
...
...
133
static void (*l_sigcleanup)(int);
133
static void (*l_sigcleanup)(int);
134
static HANDLE eWorkFinished = INVALID_HANDLE_VALUE;
134
static HANDLE eWorkFinished = INVALID_HANDLE_VALUE;
135
135
136
static BOOL WINAPI CtrlHandler(DWORD fdwCtrlType)
136
static BOOL WINAPI CtrlHandler(DWORD fdwCtrlType)
137
{
137
{
138
    LOGDEB(("CtrlHandler\n"));
138
    LOGDEB("CtrlHandler\n" );
139
    if (l_sigcleanup == 0)
139
    if (l_sigcleanup == 0)
140
        return FALSE;
140
        return FALSE;
141
141
142
    switch(fdwCtrlType) { 
142
    switch(fdwCtrlType) { 
143
    case CTRL_C_EVENT: 
143
    case CTRL_C_EVENT: 
...
...
145
    case CTRL_BREAK_EVENT: 
145
    case CTRL_BREAK_EVENT: 
146
    case CTRL_LOGOFF_EVENT: 
146
    case CTRL_LOGOFF_EVENT: 
147
    case CTRL_SHUTDOWN_EVENT:
147
    case CTRL_SHUTDOWN_EVENT:
148
    {
148
    {
149
        l_sigcleanup(SIGINT);
149
        l_sigcleanup(SIGINT);
150
        LOGDEB0(("CtrlHandler: waiting for exit ready\n"));
150
        LOGDEB0("CtrlHandler: waiting for exit ready\n" );
151
    DWORD res = WaitForSingleObject(eWorkFinished, INFINITE);
151
    DWORD res = WaitForSingleObject(eWorkFinished, INFINITE);
152
    if (res != WAIT_OBJECT_0) {
152
    if (res != WAIT_OBJECT_0) {
153
            LOGERR(("CtrlHandler: exit ack wait failed\n"));
153
            LOGERR("CtrlHandler: exit ack wait failed\n" );
154
    }
154
    }
155
        LOGDEB0(("CtrlHandler: got exit ready event, exiting\n"));
155
        LOGDEB0("CtrlHandler: got exit ready event, exiting\n" );
156
        return TRUE;
156
        return TRUE;
157
    }
157
    }
158
    default: 
158
    default: 
159
        return FALSE; 
159
        return FALSE; 
160
    } 
160
    } 
...
...
168
    case WM_ENDSESSION:
168
    case WM_ENDSESSION:
169
    case WM_DESTROY:
169
    case WM_DESTROY:
170
    case WM_CLOSE:
170
    case WM_CLOSE:
171
    {
171
    {
172
        l_sigcleanup(SIGINT);
172
        l_sigcleanup(SIGINT);
173
        LOGDEB(("MainWndProc: got end message, waiting for work finished\n"));
173
        LOGDEB("MainWndProc: got end message, waiting for work finished\n" );
174
    DWORD res = WaitForSingleObject(eWorkFinished, INFINITE);
174
    DWORD res = WaitForSingleObject(eWorkFinished, INFINITE);
175
    if (res != WAIT_OBJECT_0) {
175
    if (res != WAIT_OBJECT_0) {
176
            LOGERR(("MainWndProc: exit ack wait failed\n"));
176
            LOGERR("MainWndProc: exit ack wait failed\n" );
177
    }
177
    }
178
        LOGDEB(("MainWindowProc: got exit ready event, exiting\n"));
178
        LOGDEB("MainWindowProc: got exit ready event, exiting\n" );
179
        return TRUE;
179
        return TRUE;
180
    }
180
    }
181
    default:
181
    default:
182
        return DefWindowProc(hwnd, msg, wParam, lParam);
182
        return DefWindowProc(hwnd, msg, wParam, lParam);
183
    }
183
    }
...
...
233
    HANDLE hInvisiblethread =
233
    HANDLE hInvisiblethread =
234
        CreateThread(NULL, 0, RunInvisibleWindowThread, NULL, 0, &tid);
234
        CreateThread(NULL, 0, RunInvisibleWindowThread, NULL, 0, &tid);
235
    SetConsoleCtrlHandler((PHANDLER_ROUTINE)CtrlHandler, TRUE);
235
    SetConsoleCtrlHandler((PHANDLER_ROUTINE)CtrlHandler, TRUE);
236
    eWorkFinished = CreateEvent(NULL, TRUE, FALSE, NULL);
236
    eWorkFinished = CreateEvent(NULL, TRUE, FALSE, NULL);
237
    if (eWorkFinished == INVALID_HANDLE_VALUE) {
237
    if (eWorkFinished == INVALID_HANDLE_VALUE) {
238
        LOGERR(("initAsyncSigs: error creating exitready event\n"));
238
        LOGERR("initAsyncSigs: error creating exitready event\n" );
239
    }
239
    }
240
}
240
}
241
void recoll_exitready()
241
void recoll_exitready()
242
{
242
{
243
    LOGDEB(("recoll_exitready()\n"));
243
    LOGDEB("recoll_exitready()\n" );
244
    if (!SetEvent(eWorkFinished)) {
244
    if (!SetEvent(eWorkFinished)) {
245
        LOGERR(("recoll_exitready: SetEvent failed\n"));
245
        LOGERR("recoll_exitready: SetEvent failed\n" );
246
    }
246
    }
247
}
247
}
248
248
249
#endif
249
#endif
250
250
...
...
338
    }
338
    }
339
339
340
    bool novfork;
340
    bool novfork;
341
    config->getConfParam("novfork", &novfork);
341
    config->getConfParam("novfork", &novfork);
342
    if (novfork) {
342
    if (novfork) {
343
    LOGDEB0(("rclinit: will use fork() for starting commands\n"));
343
    LOGDEB0("rclinit: will use fork() for starting commands\n" );
344
        ExecCmd::useVfork(false);
344
        ExecCmd::useVfork(false);
345
    } else {
345
    } else {
346
    LOGDEB0(("rclinit: will use vfork() for starting commands\n"));
346
    LOGDEB0("rclinit: will use vfork() for starting commands\n" );
347
    ExecCmd::useVfork(true);
347
    ExecCmd::useVfork(true);
348
    }
348
    }
349
#endif
349
#endif
350
350
351
    int flushmb;
351
    int flushmb;
352
    if (config->getConfParam("idxflushmb", &flushmb) && flushmb > 0) {
352
    if (config->getConfParam("idxflushmb", &flushmb) && flushmb > 0) {
353
    LOGDEB1(("rclinit: idxflushmb=%d, set XAPIAN_FLUSH_THRESHOLD to 10E6\n",
353
    LOGDEB1("rclinit: idxflushmb="  << (flushmb) << ", set XAPIAN_FLUSH_THRESHOLD to 10E6\n" );
354
       flushmb));
355
    static const char *cp = "XAPIAN_FLUSH_THRESHOLD=1000000";
354
    static const char *cp = "XAPIAN_FLUSH_THRESHOLD=1000000";
356
#ifdef PUTENV_ARG_CONST
355
#ifdef PUTENV_ARG_CONST
357
    ::putenv(cp);
356
    ::putenv(cp);
358
#else
357
#else
359
    ::putenv(strdup(cp));
358
    ::putenv(strdup(cp));
...
...
388
bool recoll_ismainthread()
387
bool recoll_ismainthread()
389
{
388
{
390
    return std::this_thread::get_id() == mainthread_id;
389
    return std::this_thread::get_id() == mainthread_id;
391
}
390
}
392
391
392