Skip to content

Commit

Permalink
Fixed CORE-1017.
Browse files Browse the repository at this point in the history
  • Loading branch information
dyemanov committed Nov 28, 2006
1 parent fd02ced commit 25bf9d6
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 39 deletions.
21 changes: 10 additions & 11 deletions src/remote/inet.cpp
Expand Up @@ -390,7 +390,6 @@ static int INET_max_clients;
#ifdef WIN_NT
static bool INET_initialized = false;
static WSADATA INET_wsadata;
static TEXT INET_command_line[MAXPATHLEN + 32], *INET_p;
#endif


Expand Down Expand Up @@ -1966,17 +1965,17 @@ static int fork( SOCKET old_handle, USHORT flag)
* Create a child process.
*
**************************************/
if (!INET_command_line[0]) {
strcpy(INET_command_line, GetCommandLine());
INET_p = INET_command_line + strlen(INET_command_line);
}
TEXT name[MAXPATHLEN];
GetModuleFileName(NULL, name, sizeof(name));

HANDLE new_handle;
DuplicateHandle(GetCurrentProcess(), (HANDLE) old_handle,
GetCurrentProcess(), &new_handle, 0, TRUE,
DUPLICATE_SAME_ACCESS);

sprintf(INET_p, " -i -h %"SLONGFORMAT, (SLONG) new_handle);
Firebird::string cmdLine;
cmdLine.printf("%s -i -h %"SLONGFORMAT, name, (SLONG) new_handle);

STARTUPINFO start_crud;
start_crud.cb = sizeof(STARTUPINFO);
start_crud.lpReserved = NULL;
Expand All @@ -1987,11 +1986,11 @@ static int fork( SOCKET old_handle, USHORT flag)
start_crud.dwFlags = STARTF_FORCEOFFFEEDBACK;

PROCESS_INFORMATION pi;
if (CreateProcess(NULL, INET_command_line, NULL, NULL, TRUE,
(flag & SRVR_high_priority ?
HIGH_PRIORITY_CLASS | DETACHED_PROCESS :
NORMAL_PRIORITY_CLASS | DETACHED_PROCESS),
NULL, NULL, &start_crud, &pi))
if (CreateProcess(NULL, cmdLine.begin(), NULL, NULL, TRUE,
(flag & SRVR_high_priority ?
HIGH_PRIORITY_CLASS | DETACHED_PROCESS :
NORMAL_PRIORITY_CLASS | DETACHED_PROCESS),
NULL, NULL, &start_crud, &pi))
{
CloseHandle(pi.hThread);
CloseHandle(pi.hProcess);
Expand Down
31 changes: 12 additions & 19 deletions src/remote/os/win32/wnet.cpp
Expand Up @@ -374,9 +374,6 @@ rem_port* WNET_connect(const TEXT* name,

LPSECURITY_ATTRIBUTES security_attr = ISC_get_security_desc();
THREAD_EXIT();
TEXT command_line[MAXPATHLEN + 32];
command_line[0] = 0;
TEXT* p = 0;

while (true)
{
Expand Down Expand Up @@ -424,32 +421,28 @@ rem_port* WNET_connect(const TEXT* name,
return port;
}

if (!command_line[0])
{
strcpy(command_line, GetCommandLine());
p = command_line + strlen(command_line);
}
TEXT name[MAXPATHLEN];
GetModuleFileName(NULL, name, sizeof(name));

Firebird::string cmdLine;
cmdLine.printf("%s -w -h %"SLONGFORMAT, name, (SLONG) port->port_handle);

sprintf(p, " -w -h %"SLONGFORMAT, (SLONG) port->port_handle);
STARTUPINFO start_crud;
PROCESS_INFORMATION pi;
STARTUPINFO start_crud;
PROCESS_INFORMATION pi;
start_crud.cb = sizeof(STARTUPINFO);
start_crud.lpReserved = NULL;
start_crud.lpReserved2 = NULL;
start_crud.cbReserved2 = 0;
start_crud.lpDesktop = NULL;
start_crud.lpTitle = NULL;
start_crud.dwFlags = STARTF_FORCEOFFFEEDBACK;
const USHORT ret = CreateProcess(NULL,
command_line,
NULL,
NULL,
TRUE,
(flag & SRVR_high_priority ?

if (CreateProcess(NULL, cmdLine.begin(), NULL, NULL, TRUE,
(flag & SRVR_high_priority ?
HIGH_PRIORITY_CLASS | DETACHED_PROCESS :
NORMAL_PRIORITY_CLASS | DETACHED_PROCESS),
NULL, NULL, &start_crud, &pi);
if (ret) {
NULL, NULL, &start_crud, &pi))
{
CloseHandle(pi.hThread);
CloseHandle(pi.hProcess);
}
Expand Down
15 changes: 6 additions & 9 deletions src/remote/xnet.cpp
Expand Up @@ -75,7 +75,6 @@ static int send_partial(rem_port*, PACKET *);
static HANDLE server_process_handle = 0;
static void server_shutdown(rem_port* port);
#endif
static TEXT XNET_command_line[MAXPATHLEN + 32], *XNET_p;
static rem_port* get_server_port(ULONG, XPM, ULONG, ULONG, ULONG, ISC_STATUS*);
static bool make_map(ULONG, ULONG, FILE_ID*, CADDR_T*);
static XPM make_xpm(ULONG, ULONG);
Expand Down Expand Up @@ -1368,7 +1367,6 @@ static rem_port* connect_server(ISC_STATUS* status_vector, USHORT flag)
*
**************************************/
current_process_id = getpid();
XNET_command_line[0] = 0;

if (!server_init())
return NULL;
Expand Down Expand Up @@ -2405,12 +2403,11 @@ static bool fork(ULONG client_pid, USHORT flag, ULONG* forked_pid)
* It's for classic server only
*
**************************************/
if (!XNET_command_line[0]) {
strcpy(XNET_command_line, GetCommandLine());
XNET_p = XNET_command_line + strlen(XNET_command_line);
}
TEXT name[MAXPATHLEN];
GetModuleFileName(NULL, name, sizeof(name));

sprintf(XNET_p, " -x -h %"ULONGFORMAT, (ULONG) client_pid);
Firebird::string cmdLine;
cmdLine.printf("%s -x -h %"ULONGFORMAT, name, client_pid);

STARTUPINFO start_crud;
start_crud.cb = sizeof(STARTUPINFO);
Expand All @@ -2423,9 +2420,9 @@ static bool fork(ULONG client_pid, USHORT flag, ULONG* forked_pid)
PROCESS_INFORMATION pi;

const bool cp_result =
CreateProcess(NULL, XNET_command_line, NULL, NULL, TRUE,
CreateProcess(NULL, cmdLine.begin(), NULL, NULL, TRUE,
(flag & SRVR_high_priority ? HIGH_PRIORITY_CLASS : NORMAL_PRIORITY_CLASS)
| DETACHED_PROCESS | CREATE_SUSPENDED | STARTF_FORCEOFFFEEDBACK,
| DETACHED_PROCESS | CREATE_SUSPENDED,
NULL, NULL, &start_crud, &pi);

// Child process ID (forked_pid) used as map number
Expand Down

0 comments on commit 25bf9d6

Please sign in to comment.