diff --git a/configure.in b/configure.in index edbbc7a1b9..da0b248e35 100644 --- a/configure.in +++ b/configure.in @@ -1,4 +1,4 @@ -dnl $Id: configure.in,v 1.210 2004-11-07 13:43:43 alexpeshkoff Exp $ +dnl $Id: configure.in,v 1.211 2004-12-24 09:35:24 kkuznetsov Exp $ dnl ############################# INITIALISATION ############################### @@ -111,6 +111,8 @@ case "$target" in LOCK_MANAGER_FLG=N EDITLINE_FLG=N SHRLIB_EXT=so + PTHREAD_CFLAGS=-threads + PTHREAD_LIBS=-lthread ;; sparc-sun-solaris*) diff --git a/src/common/classes/fb_tls.h b/src/common/classes/fb_tls.h index ba56ac151a..c56cbc7aed 100644 --- a/src/common/classes/fb_tls.h +++ b/src/common/classes/fb_tls.h @@ -93,7 +93,7 @@ private: //# define TLS_SET(NAME, VALUE) NAME = (VALUE) #else -#if not (defined SOLARIS) +#if not (defined SOLARIS_MT) #include @@ -123,7 +123,7 @@ public: private: pthread_key_t key; }; -#else //SOLARIS +#else //SOLARIS_MT #include #include @@ -167,7 +167,7 @@ private: }; -#endif //SOLARIS +#endif //SOLARIS_MT } // namespace Firebird diff --git a/src/common/classes/locks.h b/src/common/classes/locks.h index f07cc9295b..cd938f0518 100644 --- a/src/common/classes/locks.h +++ b/src/common/classes/locks.h @@ -24,7 +24,7 @@ * Contributor(s): ______________________________________. * * - * $Id: locks.h,v 1.18 2004-11-07 10:52:32 robocop Exp $ + * $Id: locks.h,v 1.19 2004-12-24 09:35:39 kkuznetsov Exp $ * */ @@ -39,7 +39,7 @@ // in thd.h ? This is Windows platform maintainers choice #include #else -#ifndef SOLARIS +#ifndef SOLARIS_MT #include #else #include @@ -82,7 +82,7 @@ public: /* Process-local spinlock. Used to manage memory heaps in threaded environment. */ // Pthreads version of the class -#if !defined(SOLARIS) && !defined(DARWIN) && !defined(FREEBSD) && !defined(NETBSD) +#if !defined(SOLARIS_MT) && !defined(DARWIN) && !defined(FREEBSD) && !defined(NETBSD) class Mutex { private: pthread_spinlock_t spinlock; @@ -105,7 +105,7 @@ public: } }; #else -#ifdef SOLARIS +#ifdef SOLARIS_MT // Who knows why Solaris 2.6 have not THIS funny spins? //The next code is not comlpeted but let me compile //Konstantin class Mutex { diff --git a/src/common/classes/rwlock.h b/src/common/classes/rwlock.h index 2f08ff0b60..c80aa22fb7 100644 --- a/src/common/classes/rwlock.h +++ b/src/common/classes/rwlock.h @@ -24,7 +24,7 @@ * Contributor(s): ______________________________________. * * - * $Id: rwlock.h,v 1.23 2004-11-07 10:52:32 robocop Exp $ + * $Id: rwlock.h,v 1.24 2004-12-24 09:35:39 kkuznetsov Exp $ * */ @@ -155,7 +155,7 @@ public: #ifdef MULTI_THREAD -#ifdef SOLARIS +#ifdef SOLARIS_MT #include #include @@ -306,7 +306,7 @@ public: } // namespace Firebird -#endif /*solaris*/ +#endif /*solaris threading (not posix)*/ #else diff --git a/src/common/classes/semaphore.h b/src/common/classes/semaphore.h index 10246a50ec..9250f3d587 100644 --- a/src/common/classes/semaphore.h +++ b/src/common/classes/semaphore.h @@ -24,7 +24,7 @@ * Contributor(s): ______________________________________. * * - * $Id: semaphore.h,v 1.16 2004-11-24 09:05:12 robocop Exp $ + * $Id: semaphore.h,v 1.17 2004-12-24 09:35:39 kkuznetsov Exp $ * */ @@ -74,7 +74,7 @@ public: #ifdef MULTI_THREAD -#ifdef SOLARIS +#ifdef SOLARIS_MT /* This is dummy, untested implementation of FB::Semaphore on Solaris using conditional variable protected by mutex. I'll review it later diff --git a/src/jrd/isc.h b/src/jrd/isc.h index 66ca6a8048..f1421cc71e 100644 --- a/src/jrd/isc.h +++ b/src/jrd/isc.h @@ -111,7 +111,7 @@ typedef struct sh_mem* SH_MEM; // to avoid circular dependencies in h-files. // Alex Peshkov. Tue 08 Jun 2004 02:22:08 PM MSD. -#if (defined(SOLARIS) && defined(SOLARIS_MT)) +#if defined(SOLARIS_MT) #include #define COND_STRUCT cond_t #define MUTEX_STRUCT mutex_t diff --git a/src/jrd/thd.cpp b/src/jrd/thd.cpp index cd947bcd4d..04c18b342d 100644 --- a/src/jrd/thd.cpp +++ b/src/jrd/thd.cpp @@ -49,7 +49,7 @@ #endif -#ifdef SOLARIS +#ifdef SOLARIS_MT #include #include #endif diff --git a/src/jrd/thd.h b/src/jrd/thd.h index 4751a32c7b..e3b7c57b4f 100644 --- a/src/jrd/thd.h +++ b/src/jrd/thd.h @@ -26,7 +26,7 @@ * */ /* -$Id: thd.h,v 1.39 2004-11-24 09:22:07 robocop Exp $ +$Id: thd.h,v 1.40 2004-12-24 09:35:42 kkuznetsov Exp $ */ #ifndef JRD_THD_H @@ -108,7 +108,7 @@ const int SWEEP_QUANTUM = 10; /* Make sweeps less disruptive */ #define THREAD_ENTRY_PARAM void* #define THREAD_ENTRY_RETURN void* #define THREAD_ENTRY_CALL -#elif defined(SOLARIS) +#elif defined(SOLARIS_MT) #define THREAD_ENTRY_PARAM void* #define THREAD_ENTRY_RETURN void * #define THREAD_ENTRY_CALL diff --git a/src/utilities/guard/util.cpp b/src/utilities/guard/util.cpp index 82a3a64b3c..38e279af2b 100644 --- a/src/utilities/guard/util.cpp +++ b/src/utilities/guard/util.cpp @@ -21,10 +21,14 @@ * Contributor(s): ______________________________________. */ /* -$Id: util.cpp,v 1.5 2004-05-09 05:48:33 robocop Exp $ +$Id: util.cpp,v 1.6 2004-12-24 09:35:45 kkuznetsov Exp $ */ #include "firebird.h" +#ifdef SOLARIS_MT +#include +#endif + #include #include #include @@ -96,13 +100,24 @@ pid_t UTIL_start_process(const char* process, char** argv) /* add place in argv for visibility to "ps" */ strcpy(argv[0], string); +#if (defined SOLARIS_MT) + if (!(pid = fork1())) { + if (execv(string, argv)== -1){ + ib_fprintf(ib_stderr, "Could not create child process %s with args %s\n", + string, argv); + + } + exit(FINI_ERROR); + } + +#else pid_t pid = vfork(); if (!pid) { execv(string, argv); _exit(FINI_ERROR); } - +#endif return (pid); } diff --git a/src/utilities/ibmgr/srvrmgr.cpp b/src/utilities/ibmgr/srvrmgr.cpp index 1b58efa0ec..f02b88aa4f 100644 --- a/src/utilities/ibmgr/srvrmgr.cpp +++ b/src/utilities/ibmgr/srvrmgr.cpp @@ -23,6 +23,10 @@ */ #include "firebird.h" +#ifdef SOLARIS_MT +#include +#endif + #include #include #include @@ -489,17 +493,37 @@ static bool start_server( ibmgr_data_t* data) else argv[1] = option_f; argv[2] = NULL; - + argv[3] = NULL; #ifdef DEBUG printf("Argument list:\n\"%s\"\n\"%s\"\n", argv[0], argv[1]); #endif pid_t pid; +#if (defined SOLARIS_MT) +/* Accoding Sun's documentation vfork() is not MT-safe + while linking with libthreads, fork1 - fork one thread +*/ + if (!(pid = fork1())) { + if (execv(path, argv)== -1){ + ib_fprintf(OUTFILE, "Could not create child process %s with args %s\n", + path, argv); + + } + + + + + _exit(FINI_ERROR); + } + +#else + if (!(pid = vfork())) { execv(path, argv); _exit(FINI_ERROR); } +#endif /* Wait a little bit to let the server start */ @@ -524,12 +548,28 @@ static bool start_server( ibmgr_data_t* data) 0 if an exit status of a child process is unavailable (that means in our case that the server is running). */ +#if (defined SOLARIS_MT) +/* Trying to understand why it dead */ + if ((ret_value == pid)&&( WIFEXITED(exit_status) + ||WCOREDUMP(exit_status) + ||WIFSIGNALED(exit_status))) { + ib_printf("Guardian process %ld terminated with code %ld\n", + pid,WEXITSTATUS(exit_status)); + break; + } + +#else + + if (ret_value == pid) { #ifdef DEBUG printf("Guardian process %ld terminated\n", pid); #endif break; } + +#endif /*SOLARIS_MT*/ + #ifdef DEBUG else if (ret_value == -1) { printf("waitpid returned error, errno = %ld\n", errno);