fix: align native daemon port hash with client on Windows (#734)
The client (connection.rs) and native daemon (native/daemon.rs) used different get_port_for_session() implementations on Windows: - Client: i32, .chars(), djb2 — (hash << 5) - hash + c - Daemon: i64, .bytes(), Java hashCode — hash * 31 + b For session name "default", client computes port 50838 while the daemon binds on 51174, causing a 5-second timeout and startup failure. Fix: align native/daemon.rs to use the identical djb2 algorithm from connection.rs (i32, chars, djb2), so both sides agree on the port. Unix is unaffected (uses Unix domain sockets, no port hashing). Tests: add port hash regression tests to all three implementations (native/daemon.rs, connection.rs, daemon.ts) to prevent future drift. Fixes #705
This commit is contained in:
+1
-1
@@ -185,7 +185,7 @@ export function getSession(): string {
|
||||
* Get port number for TCP mode (Windows)
|
||||
* Uses a hash of the session name to get a consistent port
|
||||
*/
|
||||
function getPortForSession(session: string): number {
|
||||
export function getPortForSession(session: string): number {
|
||||
let hash = 0;
|
||||
for (let i = 0; i < session.length; i++) {
|
||||
hash = (hash << 5) - hash + session.charCodeAt(i);
|
||||
|
||||
Reference in New Issue
Block a user