+/*
+ * Create the indexer thread and begin its operation.
+ */
+void create_indexer_thread(void) {
+ int ret;
+ pthread_attr_t attr;
+
+ if ((ret = pthread_attr_init(&attr))) {
+ lprintf(CTDL_EMERG, "pthread_attr_init: %s\n", strerror(ret));
+ time_to_die = -1;
+ return;
+ }
+
+ /* Our per-thread stacks need to be bigger than the default size,
+ * otherwise the MIME parser crashes on FreeBSD, and the IMAP service
+ * crashes on 64-bit Linux.
+ */
+ if ((ret = pthread_attr_setstacksize(&attr, THREADSTACKSIZE))) {
+ lprintf(CTDL_EMERG, "pthread_attr_setstacksize: %s\n",
+ strerror(ret));
+ time_to_die = -1;
+ pthread_attr_destroy(&attr);
+ return;
+ }
+
+ if ((ret = pthread_create(&indexer_thread_tid, &attr, indexer_thread, NULL) != 0))
+ {
+ lprintf(CTDL_ALERT, "Can't create indexer thread: %s\n",
+ strerror(ret));
+ }
+
+ pthread_attr_destroy(&attr);
+}
+
+