remove hack in name server

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@24405 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2007-01-23 16:04:32 +00:00
parent 10bb9dcc50
commit f8949b9740
2 changed files with 22 additions and 13 deletions

View file

@ -157,8 +157,9 @@ static void clean_up_names(void)
+ (NSString *) _query: (NSString *)name + (NSString *) _query: (NSString *)name
{ {
NSString *n; NSString *mailslotName;
NSString *p; NSString *translatedName;
NSString *mailslotPath;
unsigned char buf[1024]; unsigned char buf[1024];
unsigned char *ptr = buf; unsigned char *ptr = buf;
DWORD max = 1024; DWORD max = 1024;
@ -167,8 +168,10 @@ static void clean_up_names(void)
HANDLE h; HANDLE h;
int rc; int rc;
n = [[self class] _translate: name]; translatedName = [[self class] _translate: name];
#if 0
/* FIXME ... wierd hack. /* FIXME ... wierd hack.
* It appears that RegQueryValueExW does not always read from the registry, * It appears that RegQueryValueExW does not always read from the registry,
* but will in fact return cached results (even if you close and re-open the * but will in fact return cached results (even if you close and re-open the
@ -190,10 +193,11 @@ static void clean_up_names(void)
* port. * port.
*/ */
OutputDebugStringW(L""); OutputDebugStringW(L"");
#endif
rc = RegQueryValueExW( rc = RegQueryValueExW(
key, key,
UNISTR(n), UNISTR(translatedName),
(LPDWORD)0, (LPDWORD)0,
&type, &type,
(LPBYTE)ptr, (LPBYTE)ptr,
@ -209,7 +213,7 @@ OutputDebugStringW(L"");
len = max; len = max;
rc = RegQueryValueExW( rc = RegQueryValueExW(
key, key,
UNISTR(n), UNISTR(translatedName),
(LPDWORD)0, (LPDWORD)0,
&type, &type,
(LPBYTE)ptr, (LPBYTE)ptr,
@ -224,7 +228,7 @@ OutputDebugStringW(L"");
return nil; return nil;
} }
p = [NSString stringWithUTF8String: ptr]; mailslotName = [NSString stringWithUTF8String: ptr];
if (ptr != buf) if (ptr != buf)
{ {
objc_free(ptr); objc_free(ptr);
@ -234,10 +238,10 @@ OutputDebugStringW(L"");
* See if we can open the port mailslot ... if not, the query returned * See if we can open the port mailslot ... if not, the query returned
* an old name, and we can remove it. * an old name, and we can remove it.
*/ */
p = [NSString stringWithFormat: mailslotPath = [NSString stringWithFormat:
@"\\\\.\\mailslot\\GNUstep\\NSMessagePort\\%@", p]; @"\\\\.\\mailslot\\GNUstep\\NSMessagePort\\%@", mailslotName];
h = CreateFileW( h = CreateFileW(
UNISTR(p), UNISTR(mailslotPath),
GENERIC_WRITE, GENERIC_WRITE,
FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE,
&security, &security,
@ -246,13 +250,16 @@ OutputDebugStringW(L"");
(HANDLE)0); (HANDLE)0);
if (h == INVALID_HANDLE_VALUE) if (h == INVALID_HANDLE_VALUE)
{ {
RegDeleteValueW(key, UNISTR(n)); NSDebugLLog(@"NSMessagePortNameServer",
@"Failed to open mailslot (%@) for write on port named %@ - %@",
mailslotPath, name, [NSError _last]);
//RegDeleteValueW(key, UNISTR(n));
return nil; return nil;
} }
else else
{ {
CloseHandle(h); // OK CloseHandle(h); // OK
return n; return mailslotName;
} }
} }
@ -341,6 +348,7 @@ OutputDebugStringW(L"");
REG_BINARY, REG_BINARY,
str, str,
strlen(str)+1); strlen(str)+1);
NSDebugLLog(@"NSMessagePortNameServer", @"Set port '%s' for %@", str, n);
if (rc == ERROR_SUCCESS) if (rc == ERROR_SUCCESS)
{ {
rc = RegFlushKey(key); rc = RegFlushKey(key);

View file

@ -162,6 +162,9 @@ static Class messagePortClass = 0;
(HANDLE)0); (HANDLE)0);
if (this->wHandle == INVALID_HANDLE_VALUE) if (this->wHandle == INVALID_HANDLE_VALUE)
{ {
NSDebugMLLog(@"NSMessagePort",
@"unable to access mailslot '%@' for write - %@",
[self name], [NSError _last]);
result = NO; result = NO;
} }
else else
@ -396,8 +399,6 @@ static Class messagePortClass = 0;
*/ */
if ([self _setupSendPort] == NO) if ([self _setupSendPort] == NO)
{ {
NSLog(@"unable to access mailslot '%@' - %@",
[self name], [NSError _last]);
DESTROY(self); DESTROY(self);
} }