mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 16:30:41 +00:00
Fix for notification queue item removal and for availableData
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@5246 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
51fe7f149c
commit
9e3c780110
3 changed files with 158 additions and 92 deletions
|
@ -1,3 +1,12 @@
|
|||
Sun Nov 21 6:35:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||
|
||||
* Source/NSNotificationQueue.m: Applied patch by Dan Pascu to fix bug
|
||||
in removal of notificatiosn from queues. Also tidied indentation etc
|
||||
to conform to GNU standards.
|
||||
* Source/UnixFileHandle.m: ([-availableData]) fixed to block when no
|
||||
data is availabvle on a comms channel - as per spec. This bug was
|
||||
also reported by Dan <dan@services.iirux.ro>
|
||||
|
||||
1999-11-18 Adam Fedor <fedor@gnu.org>
|
||||
|
||||
* Source/GNUmakefile: Install unicode headers.
|
||||
|
|
|
@ -103,19 +103,22 @@ currentList()
|
|||
NotificationQueueList *list;
|
||||
NotificationQueueList *elem;
|
||||
|
||||
if (q == nil)
|
||||
return; /* Can't register nil object. */
|
||||
|
||||
list = currentList(); /* List of queues for thread. */
|
||||
|
||||
if (list->queue == nil)
|
||||
{
|
||||
list->queue = q; /* Make this the default. */
|
||||
}
|
||||
|
||||
while (list->queue != q && list->next != nil)
|
||||
{
|
||||
list = list->next;
|
||||
}
|
||||
|
||||
if (list->queue == q)
|
||||
{
|
||||
return; /* Queue already registered. */
|
||||
}
|
||||
|
||||
elem = (NotificationQueueList*)NSAllocateObject(self, 0,
|
||||
NSDefaultMallocZone());
|
||||
|
@ -127,9 +130,6 @@ currentList()
|
|||
{
|
||||
NotificationQueueList *list;
|
||||
|
||||
if (q == nil)
|
||||
return;
|
||||
|
||||
list = currentList();
|
||||
|
||||
if (list->queue == q)
|
||||
|
@ -145,8 +145,10 @@ currentList()
|
|||
RELEASE(tmp); /* retained in dictionary. */
|
||||
}
|
||||
else
|
||||
{
|
||||
[d removeObjectForKey: tkey];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while (list->next != nil)
|
||||
|
@ -197,8 +199,7 @@ typedef struct _NSNotificationQueueList
|
|||
*/
|
||||
|
||||
static inline void
|
||||
remove_from_queue_no_release(
|
||||
NSNotificationQueueList* queue,
|
||||
remove_from_queue_no_release(NSNotificationQueueList *queue,
|
||||
NSNotificationQueueRegistration *item)
|
||||
{
|
||||
if (item->prev)
|
||||
|
@ -229,10 +230,8 @@ remove_from_queue_no_release(
|
|||
}
|
||||
|
||||
static void
|
||||
remove_from_queue(
|
||||
NSNotificationQueueList* queue,
|
||||
NSNotificationQueueRegistration* item,
|
||||
NSZone* _zone)
|
||||
remove_from_queue(NSNotificationQueueList *queue,
|
||||
NSNotificationQueueRegistration *item, NSZone *_zone)
|
||||
{
|
||||
remove_from_queue_no_release(queue, item);
|
||||
RELEASE(item->notification);
|
||||
|
@ -241,14 +240,12 @@ remove_from_queue(
|
|||
}
|
||||
|
||||
static void
|
||||
add_to_queue(
|
||||
NSNotificationQueueList* queue,
|
||||
NSNotification* notification,
|
||||
NSArray* modes,
|
||||
NSZone* _zone)
|
||||
add_to_queue(NSNotificationQueueList *queue, NSNotification *notification,
|
||||
NSArray *modes, NSZone *_zone)
|
||||
{
|
||||
NSNotificationQueueRegistration* item =
|
||||
NSZoneCalloc(_zone, 1, sizeof(NSNotificationQueueRegistration));
|
||||
NSNotificationQueueRegistration *item;
|
||||
|
||||
item = NSZoneCalloc(_zone, 1, sizeof(NSNotificationQueueRegistration));
|
||||
|
||||
item->notification = RETAIN(notification);
|
||||
item->name = [notification name];
|
||||
|
@ -259,10 +256,14 @@ add_to_queue(
|
|||
item->next = queue->tail;
|
||||
queue->tail = item;
|
||||
if (item->next)
|
||||
{
|
||||
item->next->prev = item;
|
||||
}
|
||||
if (!queue->head)
|
||||
{
|
||||
queue->head = item;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -304,7 +305,9 @@ add_to_queue(
|
|||
_asapQueue = NSZoneCalloc(_zone, 1, sizeof(NSNotificationQueueList));
|
||||
_idleQueue = NSZoneCalloc(_zone, 1, sizeof(NSNotificationQueueList));
|
||||
|
||||
// insert in global queue list
|
||||
/*
|
||||
* insert in global queue list
|
||||
*/
|
||||
[NotificationQueueList registerQueue: self];
|
||||
|
||||
return self;
|
||||
|
@ -314,16 +317,24 @@ add_to_queue(
|
|||
{
|
||||
NSNotificationQueueRegistration *item;
|
||||
|
||||
// remove from class instances list
|
||||
/*
|
||||
* remove from class instances list
|
||||
*/
|
||||
[NotificationQueueList unregisterQueue: self];
|
||||
|
||||
// release self
|
||||
/*
|
||||
* release self from queues
|
||||
*/
|
||||
for (item = _asapQueue->head; item; item=item->prev)
|
||||
{
|
||||
remove_from_queue(_asapQueue, item, _zone);
|
||||
}
|
||||
NSZoneFree(_zone, _asapQueue);
|
||||
|
||||
for (item = _idleQueue->head; item; item=item->prev)
|
||||
{
|
||||
remove_from_queue(_idleQueue, item, _zone);
|
||||
}
|
||||
NSZoneFree(_zone, _idleQueue);
|
||||
|
||||
RELEASE(_center);
|
||||
|
@ -340,39 +351,80 @@ add_to_queue(
|
|||
id name = [notification name];
|
||||
id object = [notification object];
|
||||
|
||||
// find in ASAP notification in queue
|
||||
if ((coalesceMask & NSNotificationCoalescingOnName)
|
||||
&& (coalesceMask & NSNotificationCoalescingOnSender))
|
||||
{
|
||||
/*
|
||||
* find in ASAP notification in queue matching both
|
||||
*/
|
||||
for (item = _asapQueue->tail; item; item = next)
|
||||
{
|
||||
next = item->next;
|
||||
if ((coalesceMask & NSNotificationCoalescingOnName)
|
||||
&& [name isEqual: item->name])
|
||||
if ((object == item->object) && [name isEqual: item->name])
|
||||
{
|
||||
remove_from_queue(_asapQueue, item, _zone);
|
||||
continue;
|
||||
}
|
||||
if ((coalesceMask & NSNotificationCoalescingOnSender)
|
||||
&& (object == item->object))
|
||||
{
|
||||
remove_from_queue(_asapQueue, item, _zone);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// find in idle notification in queue
|
||||
/*
|
||||
* find in idle notification in queue matching both
|
||||
*/
|
||||
for (item = _idleQueue->tail; item; item = next)
|
||||
{
|
||||
next = item->next;
|
||||
if ((coalesceMask & NSNotificationCoalescingOnName)
|
||||
&& [name isEqual: item->name])
|
||||
if ((object == item->object) && [name isEqual: item->name])
|
||||
{
|
||||
remove_from_queue(_asapQueue, item, _zone);
|
||||
continue;
|
||||
remove_from_queue(_idleQueue, item, _zone);
|
||||
}
|
||||
if ((coalesceMask & NSNotificationCoalescingOnSender)
|
||||
&& (object == item->object))
|
||||
}
|
||||
}
|
||||
else if ((coalesceMask & NSNotificationCoalescingOnName))
|
||||
{
|
||||
/*
|
||||
* find in ASAP notification in queue matching name
|
||||
*/
|
||||
for (item = _asapQueue->tail; item; item = next)
|
||||
{
|
||||
next = item->next;
|
||||
if ([name isEqual: item->name])
|
||||
{
|
||||
remove_from_queue(_asapQueue, item, _zone);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* find in idle notification in queue matching name
|
||||
*/
|
||||
for (item = _idleQueue->tail; item; item = next)
|
||||
{
|
||||
next = item->next;
|
||||
if ([name isEqual: item->name])
|
||||
{
|
||||
remove_from_queue(_idleQueue, item, _zone);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((coalesceMask & NSNotificationCoalescingOnSender))
|
||||
{
|
||||
/*
|
||||
* find in ASAP notification in queue matching sender
|
||||
*/
|
||||
for (item = _asapQueue->tail; item; item = next)
|
||||
{
|
||||
next = item->next;
|
||||
if (object == item->object)
|
||||
{
|
||||
remove_from_queue(_asapQueue, item, _zone);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* find in idle notification in queue matching sender
|
||||
*/
|
||||
for (item = _idleQueue->tail; item; item = next)
|
||||
{
|
||||
next = item->next;
|
||||
if (object == item->object)
|
||||
{
|
||||
remove_from_queue(_idleQueue, item, _zone);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -457,9 +509,13 @@ GSNotifyASAP()
|
|||
NotificationQueueList *item;
|
||||
|
||||
for (item = currentList(); item; item = item->next)
|
||||
{
|
||||
if (item->queue)
|
||||
{
|
||||
notifyASAP(item->queue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static inline void notifyIdle(NSNotificationQueue *q)
|
||||
{
|
||||
|
@ -492,9 +548,13 @@ GSNotifyIdle()
|
|||
NotificationQueueList *item;
|
||||
|
||||
for (item = currentList(); item; item = item->next)
|
||||
{
|
||||
if (item->queue)
|
||||
{
|
||||
notifyIdle(item->queue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BOOL
|
||||
GSNotifyMore()
|
||||
|
@ -502,8 +562,12 @@ GSNotifyMore()
|
|||
NotificationQueueList *item;
|
||||
|
||||
for (item = currentList(); item; item = item->next)
|
||||
{
|
||||
if (item->queue && ((accessQueue)item->queue)->_idleQueue->head)
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
|
|
|
@ -687,12 +687,6 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin)
|
|||
strerror(errno)];
|
||||
}
|
||||
|
||||
if (count == 0)
|
||||
{
|
||||
len = 0; /* End-of-file */
|
||||
}
|
||||
else
|
||||
{
|
||||
if (count > sizeof(buf))
|
||||
{
|
||||
count = sizeof(buf);
|
||||
|
@ -702,7 +696,6 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin)
|
|||
[d appendBytes: buf length: len];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (len < 0)
|
||||
{
|
||||
[NSException raise: NSFileHandleOperationException
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue