Repository navigation
Add Unix domain socket support for Firebird 6 - #73
Pavlushechko wants to merge 7 commits into
Conversation
| env string | ||
| }{ | ||
| {"TCP", "FBX_TEST_DATABASE"}, | ||
| {"Unix", "FBX_TEST_UNIX_SOCKET_DATABASE"}, |
There was a problem hiding this comment.
It would be nice to add separate testcases for event manager and service manager connections
There was a problem hiding this comment.
Added separate integration tests for both managers. The event test checks that a notification is delivered, and the service test runs TraceList. Both passed over Unix sockets with TCP disabled on Linux and Windows.
| // | ||
| // # Keyword/Value | ||
| // user=sysdba password=masterkey host=localhost port=3050 database=employee.fdb | ||
| // user=sysdba password=masterkey host=/run/firebird/firebird.sock database=employee |
There was a problem hiding this comment.
We should also support URI syntax when connecting with socket. Some pgx tests were cleaned up, but now can be restored or used as reference to check if we properly parse URI.
There was a problem hiding this comment.
I checked the original pgx cases. The existing parser already accepts firebird:///employee?host=/run/firebird/firebird.sock. I documented that form and added parsing tests for Linux and Windows paths, plus a percent-encoded path in the URI host.
| echo Start RDB | ||
| if [ -e /etc/init.d/reddatabase ]; then | ||
| /etc/init.d/reddatabase start | ||
| /etc/init.d/reddatabase "$service_action" |
There was a problem hiding this comment.
Red Database is stopped after installation (Firebird started by default), there is no point to restart
There was a problem hiding this comment.
Removed the restart. CI now configures the socket before starting Red Database, since the installer leaves it stopped.
|
|
||
| switch m := msg.(type) { | ||
| case *fbproto.OpResponse: | ||
| if isAbsolutePath(fbConn.eventHost) { |
There was a problem hiding this comment.
After Hijack followed by Construct on a working Unix connection, the first QueueEvent calls DialFunc with tcp localhost:28016. Construct does not restore eventHost, so this branch reads the m and p bytes of /tmp/. as a TCP port.
There was a problem hiding this comment.
Hijack now saves the selected host, and Construct restores it. I added a regression test that queues an event after reconstructing a Unix connection.
| address := net.JoinHostPort(host, strconv.Itoa(auxPort)) | ||
| auxConn, err := fbConn.config.DialFunc(ctx, "tcp", address) | ||
| network, address := NetworkAddress(host, port) | ||
| auxConn, err := fbConn.config.DialFunc(ctx, network, address) |
There was a problem hiding this comment.
Once Firebird has returned the auxiliary address, it is waiting for the second connection. If FBX rejects the address or the dial fails here, QueueEvent returns an error but the next Ping on the same attachment reaches its deadline. This reproduced with a one-second timeout.
On protocols 13+, libfbclient sends op_abort_aux_connection on a failed auxiliary connect and marks the attachment broken. Could we cancel the pending accept on both error paths and test that the next operation completes promptly?
There was a problem hiding this comment.
Both paths now close the connection and send op_abort_aux_connection on protocol 13+. The tests verify that Ping returns a connection-closed error before its deadline. I also covered the case where Firebird rejects the request before returning an address. In that case, Ping still succeeds.
| if isAbsolutePath(fbConn.eventHost) { | ||
| // Firebird sends the auxiliary socket path as raw bytes for Unix connections. | ||
| path := string(m.Data) | ||
| if !isAbsolutePath(path) { |
There was a problem hiding this comment.
With RemoteServiceUnixSocket = sockets/fb.sock, Firebird 6 returns sockets/fb_event.<pid>.<n> even when the client opened the main socket using an absolute path. Both libfbclient and Jaybird Native delivered the event when the client’s working directory resolved that path. FBX rejects the reply here before calling DialFunc.
There was a problem hiding this comment.
FBX now passes the relative path returned by Firebird to DialFunc with the unix network. I added a regression test and verified event delivery on Firebird 6 in WSL with a relative socket path and TCP disabled.
Fixes #71
Accepts a Unix domain socket path in host= for database connections and event notifications.
Verified on Firebird 6 in Ubuntu WSL and native Windows with TCP disabled. The integration test used a temporary version-parser fix and depends on #49.