Never use signal handlers to call sqlite3_* functions. Your handler
can be called while another sqlite3_* call is in process but sqlite3_*
functions are not re-entrant, so such code will lead to any kind of
bizarre behavior (including any sort of segmentation fault). Use your
signal handler to set some flag which will be checked in necessary
places of your application and connection will be closed if it's
set...


Pavel

On Fri, Dec 4, 2009 at 4:18 AM, liubin liu <7101...@sina.com> wrote:
>
> Thank you
>
> I do the job as you say, but the problem is still here.
>
> There are several processes who write the database. And the place is not
> same each time that the problem happens.
>
> How could I know the reason exactly?
>
> PS:
> I used the signal to close the connection to database. Just like:
>
> int main ()
> {
>    ...
>    signal (SIGUSR2, (void*)sig_handler);
>    ....
> }
>
> void sig_handler(int sig)
> {
>    ...
>    switch(sig)
>    {
>        case SIGUSR2:
>            ...
>            sqlite3_interrupt (db);
>            ret = sqlite3_close (db);  // is blocked here
>            ...
>    }
>    ...
> }
>
>
>
>
> Pavel Ivanov-2 wrote:
>>
>>> Because there are several process who use the database. I have another
>>> question:Could I close the database of other process in main process?
>>
>> Just use your favorite IPC mechanism and write your application so
>> that main process sends message to other process and when other
>> process receives it then it closes its database connection...
>>
>> Pavel
>>
>> On Sun, Nov 29, 2009 at 7:46 PM, liubin liu <7101...@sina.com> wrote:
>>>
>>> Thank you!
>>>
>>> I'm sorry for not showing clearly the environment is embedded linux on
>>> arm
>>> board.
>>>
>>> Because there are several process who use the database. I have another
>>> question:Could I close the database of other process in main process?
>>>
>>>
>>> Nick Shaw-3 wrote:
>>>>
>>>> By "other process" do you mean a separate DLL or similar?  You can't
>>>> free memory allocated in a DLL from an application, even when that
>>>> application has the DLL loaded - Windows will complain.  This could be
>>>> what's happening.
>>>>
>>>> Could you instead write the database close call within this other
>>>> process, and call it from the main process when you shut down?
>>>>
>>>> Nick.
>>>>
>>>> -----Original Message-----
>>>> From: sqlite-users-boun...@sqlite.org
>>>> [mailto:sqlite-users-boun...@sqlite.org] On Behalf Of liubin liu
>>>> Sent: 26 November 2009 02:29
>>>> To: sqlite-users@sqlite.org
>>>> Subject: [sqlite] sqlite3 is blocked by transaction when wanting to
>>>> close the sqlite3 *
>>>>
>>>>
>>>> My application includes a main process and some other processes. I open
>>>> the
>>>> database in other process, but at end I will close the database in main
>>>> process.
>>>>
>>>> The problem happens while I close the database. The main process is
>>>> blocked.
>>>> And I could see the journal file is still there, so I guess there are
>>>> still
>>>> some transactions.
>>>>
>>>> How resolve the problem?
>>>>
>>>> Thanks in advance!
>>>> --
>>>> View this message in context:
>>>> http://old.nabble.com/sqlite3-is-blocked-by-transaction-when-wanting-to-
>>>> close-the-sqlite3-*-tp26523551p26523551.html
>>>> Sent from the SQLite mailing list archive at Nabble.com.
>>>>
>>>> _______________________________________________
>>>> sqlite-users mailing list
>>>> sqlite-users@sqlite.org
>>>> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>>>> _______________________________________________
>>>> sqlite-users mailing list
>>>> sqlite-users@sqlite.org
>>>> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>>>>
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://old.nabble.com/sqlite3-is-blocked-by-transaction-when-closing-the-sqlite3-*-tp26523551p26568098.html
>>> Sent from the SQLite mailing list archive at Nabble.com.
>>>
>>> _______________________________________________
>>> sqlite-users mailing list
>>> sqlite-users@sqlite.org
>>> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>>>
>> _______________________________________________
>> sqlite-users mailing list
>> sqlite-users@sqlite.org
>> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>>
>>
>
> --
> View this message in context: 
> http://old.nabble.com/sqlite3-is-blocked-by-transaction-when-closing-the-sqlite3-*-tp26523551p26635818.html
> Sent from the SQLite mailing list archive at Nabble.com.
>
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to