* shared_info.h: Match shared_name declaration with below change.

* shared.cc (shared_name): Use incoming char * parameter instead of
	local static buffer.
	(open_shared): Accomodate new calling convention for shared_name.
	* exceptions.cc (events_init): Ditto.
	* sigproc.cc (getsem): Ditto.
	* syscalls.cc (login): Ditto.
	(logout): Ditto.
	(pututline): Ditto.
This commit is contained in:
Corinna Vinschen 2003-05-21 08:01:57 +00:00
parent 3a9c82d011
commit 5c768c978c
6 changed files with 35 additions and 14 deletions

View File

@ -1,7 +1,19 @@
2003-05-21 Corinna Vinschen <corinna@vinschen.de>
* shared_info.h: Match shared_name declaration with below change.
* shared.cc (shared_name): Use incoming char * parameter instead of
local static buffer.
(open_shared): Accomodate new calling convention for shared_name.
* exceptions.cc (events_init): Ditto.
* sigproc.cc (getsem): Ditto.
* syscalls.cc (login): Ditto.
(logout): Ditto.
(pututline): Ditto.
2003-05-20 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (secret_event_name): Return void. Use incoming
char *parameter instead of local static buffer.
char * parameter instead of local static buffer.
(fhandler_socket::create_secret_event): Accomodate new calling
convention for secret_event_name.
(fhandler_socket::close_secret_event): Ditto.

View File

@ -1134,11 +1134,13 @@ void
events_init (void)
{
char *name;
char mutex_name[MAX_PATH];
/* title_mutex protects modification of console title. It's necessary
while finding console window handle */
if (!(title_mutex = CreateMutex (&sec_all_nih, FALSE,
name = shared_name ("title_mutex", 0))))
name = shared_name (mutex_name,
"title_mutex", 0))))
api_fatal ("can't create title mutex '%s', %E", name);
ProtectHandle (title_mutex);

View File

@ -33,17 +33,16 @@ mount_info NO_COPY *mount_table;
HANDLE NO_COPY cygwin_mount_h;
char * __stdcall
shared_name (const char *str, int num)
shared_name (char *ret_buf, const char *str, int num)
{
static NO_COPY char buf[MAX_PATH] = {0};
extern bool _cygwin_testing;
__small_sprintf (buf, "%s%s.%s.%d",
__small_sprintf (ret_buf, "%s%s.%s.%d",
wincap.has_terminal_services () ? "Global\\" : "",
cygwin_version.shared_id, str, num);
if (_cygwin_testing)
strcat (buf, cygwin_version.dll_build_date);
return buf;
strcat (ret_buf, cygwin_version.dll_build_date);
return ret_buf;
}
#define page_const (65535)
@ -88,11 +87,12 @@ open_shared (const char *name, int n, HANDLE &shared_h, DWORD size, shared_locat
if (!shared_h)
{
char *mapname;
char map_buf[MAX_PATH];
if (!name)
mapname = NULL;
else
{
mapname = shared_name (name, n);
mapname = shared_name (map_buf, name, n);
shared_h = OpenFileMappingA (FILE_MAP_READ | FILE_MAP_WRITE,
TRUE, mapname);
}

View File

@ -186,5 +186,5 @@ struct console_state
};
#endif
char *__stdcall shared_name (const char *, int);
char *__stdcall shared_name (char *, const char *, int);
void *__stdcall open_shared (const char *name, int n, HANDLE &shared_h, DWORD size, shared_locations);

View File

@ -883,6 +883,7 @@ static HANDLE __stdcall
getsem (_pinfo *p, const char *str, int init, int max)
{
HANDLE h;
char sem_name[MAX_PATH];
if (p != NULL)
{
@ -906,7 +907,7 @@ getsem (_pinfo *p, const char *str, int init, int max)
DWORD winpid = GetCurrentProcessId ();
h = CreateSemaphore (sec_user_nih (sa_buf), init, max,
str = shared_name (str, winpid));
str = shared_name (sem_name, str, winpid));
p = myself;
if (!h)
{
@ -917,7 +918,7 @@ getsem (_pinfo *p, const char *str, int init, int max)
else
{
h = OpenSemaphore (SEMAPHORE_ALL_ACCESS, FALSE,
shared_name (str, p->dwProcessId));
shared_name (sem_name, str, p->dwProcessId));
if (!h)
{

View File

@ -2540,7 +2540,9 @@ login (struct utmp *ut)
pututline (ut);
endutent ();
/* Writing to wtmp must be atomic to prevent mixed up data. */
HANDLE mutex = CreateMutex (NULL, FALSE, shared_name ("wtmp_mutex", 0));
char mutex_name[MAX_PATH];
HANDLE mutex = CreateMutex (NULL, FALSE,
shared_name (mutex_name, "wtmp_mutex", 0));
if (mutex)
while (WaitForSingleObject (mutex, INFINITE) == WAIT_ABANDONED)
;
@ -2578,7 +2580,9 @@ logout (char *line)
memset (ut_buf.ut_user, 0, sizeof ut_buf.ut_user);
time (&ut_buf.ut_time);
/* Writing to wtmp must be atomic to prevent mixed up data. */
HANDLE mutex = CreateMutex (NULL, FALSE, shared_name ("wtmp_mutex", 0));
char mutex_name[MAX_PATH];
HANDLE mutex = CreateMutex (NULL, FALSE,
shared_name (mutex_name, "wtmp_mutex", 0));
if (mutex)
while (WaitForSingleObject (mutex, INFINITE) == WAIT_ABANDONED)
;
@ -2747,7 +2751,9 @@ pututline (struct utmp *ut)
return;
/* Read/write to utmp must be atomic to prevent overriding data
by concurrent processes. */
HANDLE mutex = CreateMutex (NULL, FALSE, shared_name ("utmp_mutex", 0));
char mutex_name[MAX_PATH];
HANDLE mutex = CreateMutex (NULL, FALSE,
shared_name (mutex_name, "utmp_mutex", 0));
if (mutex)
while (WaitForSingleObject (mutex, INFINITE) == WAIT_ABANDONED)
;