Repository navigation
Refactor connection state management (#326) - #329
Conversation
There was a problem hiding this comment.
I know this seems a detail, but I think the character ü was missed here. :) I also noticed some other missing chars in the japanese files too.
|
I think your changes are excellent, @roji ! I did a comment about some missing chars in the resource files. Also, another point is that you removed the NpgsqlNetworkStream. Currently this class was created to fix a problem when closing the connections from the pool when an application was finished. You can see more information about this problem and my fix here: http://lists.pgfoundry.org/pipermail/npgsql-devel/2011-December/001183.html Unless we fix it in another way, if we remove the NpgsqlNetworkStream and its override of Dispose(), we would get a regression where this message would appear again in the server logs. Also, I noticed that at the time I wrote this fix, it used to work on Mono. Now, I notice that it isn't working on Mono anymore, only on ms .Net. I think Mono isn't being able to call my Dispose override. I don't know if ms.net 4.0 or 4.5 adds any support to notify applications and assemblies when an application domain is being unloaded. If there is such support, we could use it to signalize NpgsqlConnectorPool that the assembly is being unloaded and that it should close all connections in the pools. Another usage for NpgsqlNetworkStream I foresee is to refactor PGUtil methods and add them to the NpgsqlNetworkStream itself. As you already noticed in other parts of Npgsql, some methods aren't so object oriented. PGUtil methods are such methods. I think a lot of them could be easily moved to a stream class. Or maybe we could use some extension methods to add support to the BufferedStream class. What do you think? |
|
Hi @franciscojunior! Thank you very much for taking the time to review, it's not easy to read big diffs like the one for this PR :) Comments:
Note that I rewrote the branch history and force-pushed. Let me know if you see any other issues. |
15e7321 to
8366126
Compare
|
Please hold off on reviewing this, I still have one correction I'll do later today. |
4e7e79f to
ce31156
Compare
Apart from the reshuffle, everything was more or less left as is, as much as possible. This is a WIP commit, the project does not compile.
- Grouped relevant methods in #regions - Converted some fields/properties into auto properties This is a WIP commit, the project does not compile.
- Redefined state as an Npgsql-specific enum on the connector. It's the single source of truth on state. - The state now tracks query state as well, with the values Executing and Fetching. Previously the reader was checked to know whether we were fetching. - NpgsqlConnection.State now returns the Connecting value as per MSDN docs - NpgsqlConnection.FullState now returns ConnectionState's reserved values (Executing and Fetching, Broken to be added) - Removed some remaining legacy code for pre-9.0 backends All unit tests pass
Thanks @franciscojunior for clarifying in npgsql#314.
|
I think everything is OK now. @franciscojunior (and anyone else who has time), let me know if you're OK with merging. |
Excellent, @roji ! I'll have a look and will let you know if I find anything else. |
There was a problem hiding this comment.
In a next review, we can remove all references to "Shared" connections. In the beginning we had the idea of using it because we thought it would be used. But after learning more about the ADO.Net connection semantics, we never implemented it.
|
+1 to merge. I reviewed and it seems very good! |
Refactor connection state management (#326)
The code contained traces from a partial implementation of shared connections that was never released. Cleaned up as suggested by @franciscojunior in #329 (comment)
This PR does the work described in #326. All unit tests pass.
I've split the work into 3 commits, and tried to make each as clear and self-contained as possible, to help reviews.
I'd really appreciate if you guys could take a look, this touches on some very fundamental things.