1. Beatrix Willius
  2. Valentina Server
  3. 木, 1月 17 2019, 09:05 AM
  4.  メールで購読
As usual I must be doing something stupid when reconnecting to the server:

Situation: I have simulated the loss of connection by simply doing a shutdown of the server. However, when closing the connection in my app before connecting to another database also makes the app crash. The crash is so hard that I don't even get a crash log.

I would like to get an opinion if there is something obviously stupid with the code I'm using for connecting. I have omitted the obvious stuff like setting the parameters for database, server etc and any error handling.

Constructor:


Valentina.ShutDown()
Disconnect
ConnectServer
if theDatabaseConnection <> Nil and theDatabaseConnection.IsConnected then OpenDBServer


Disconnect:


if theDatabase <> nil then
if theDatabase.IsOpen then theDatabase.Close()
theDBFolderitem = nil
theDatabase = nil
end if

'close valentina
if isClientServer then
if theDatabaseConnection <> nil and theDatabaseConnection.IsConnected then
theDatabaseConnection.Close()
end if

theDatabaseConnection = Nil
theServer = Nil

end if


ConnectServer:


Valentina.InitClient()

dim ConnectionThread as new getConnectionThread(Host, Login, ServerPassword, Port, conserv, MaxUsers)
ConnectionThread.Run
dim Timeout as Integer = Ticks + 30 * 60
While not ConnectionThread.ConnectionIsOpen
if Ticks > Timeout then
'some code
end if
app.SleepCurrentThread(10)
Wend

'got some problems
if ConnectionThread.ProblemsOccurred then
'some code
end if

'everything went fine
theDatabaseConnection = ConnectionThread.getConnection
theServer = new VServer(theDatabaseConnection)


getConnectionThread:

theDatabaseConnection = new VConnection(Host, Login, ServerPassword, Port, 30, conserv)
theDatabaseConnection.Open()


Because this code crashes so hard I don't have a good idea what might go wrong here.

Mit freundlichen Grüßen/Regards

Beatrix Willius

http://www.mothsoftware.com
Mail Archiver X: The email archiving solution for professionals
コメント
There are no comments made yet.
Beatrix Willius 承諾済みの回答
If I screw up I expect an exception. If I really screw up I expect a crash with a crash log. I expect NEVER EVER to have my app silently die.

Really. That is what exceptions and crash logs are for. What I have seen is that the exceptions happen. But the app dies to fast to react to them. It cost me a lot of time last week to pinpoint the exceptions.
コメント
There are no comments made yet.
Ruslan Zasukhin 承諾済みの回答
Hi Trixi,

// But should my app crash when the reference in a cursor to a database isn't correct?//

well, V4RB plugin and other plugins do some protections in DEBUG mode.
We consider mode as debug when you enable LogLevel > 0
Then inside of plugins start to work special code which tries to protect something and yet do diagnostic/log where possible,


You are a developer, and you write some code.
If the code is wrong, then yes you get crash or error or logs.

Our plugin + engine cannot protect from all possible errors in code, right?

something we did.

I think LOCAL db engine survive if a cursor is not destroyed.
For client-server (this is another DLL: VCLIENT) may be this is hard or not possible OR maybe we did not add it there.
コメント
There are no comments made yet.
Beatrix Willius 承諾済みの回答
After a lot of debugging at least my app doesn't crash anymore when reconnecting to a database.

I had - since time immemorial - cursors not as property but dragged to a window. The cursors have a reference to the database. The local version can happily change the reference when a new database is opened. The server version throws a hissy fit and simply dies. No exception, no crash log, nothing in the console: just nothing.

I have not removed the cursors from the window and made them properties so that I can properly Nil everything when a database is closed.

That the references weren't changed properly of course is my fault. But should my app crash when the reference in a cursor to a database isn't correct?
コメント
There are no comments made yet.
Beatrix Willius 承諾済みの回答
Thanks, Ivan. I'll change my code. I don't think that this is the problem here.

Did a bit investigating: I'm not resetting the references for some cursors. The code

#if App.kMaxVersion = Globals.Version.Server then
if mConnection = nil or mConnection.Connection = Nil or not mConnection.Connection.isConnected then Return False
#Endif

gives an Exception

"Storage encoding
" is not supported.

and then the app dies when I try to view mConnection (which is nil) in the debugger.
コメント
There are no comments made yet.
Ivan Smahin 承諾済みの回答
Valentina.ShutDown()
Disconnect


It seems to be incorrect. Valentina.ShutDown means - no calls anymore to Valentina after it. The same is for ValentinaInit. You'd better call them on app.start/close only.
コメント
There are no comments made yet.
  • ページ :
  • 1


There are no replies made for this post yet.
However, you are not allowed to reply to this post.

Categories

Announcements & News
  1. 0 subcategories
Valentina Studio
  1. 2 subcategories
Valentina Server
  1. 4 subcategories
Valentina Database ADK
  1. 0 subcategories
Valentina Reports ADK
  1. 0 subcategories
Other Discussions
  1. 0 subcategories
BETA Testing
  1. 0 subcategories
Education & Research
  1. 0 subcategories
Omegabundle
  1. 0 subcategories