From f1d119a500a9294c81330ecd52a3221578a22bc3 Mon Sep 17 00:00:00 2001 From: Sergio Lopez Date: Wed, 10 Aug 2005 17:33:37 +0200 Subject: Don't forget to update port sequence numbers in stub functions. * seqnos.c (_pager_stubs_update_seqno): New function. * priv.h (_pager_stubs_update_seqno): New function. * notify-stubs.c (_pager_do_seqnos_mach_notify_port_deleted): Call _pager_stubs_update_seqno to properly update seqno. (_pager_do_seqnos_mach_notify_msg_accepted): Likewise. (_pager_do_seqnos_mach_notify_port_destroyed): Likewise. (_pager_do_seqnos_mach_notify_send_once): Likewise. (_pager_do_seqnos_mach_notify_dead_name): Likewise. * stubs.c (_pager_seqnos_memory_object_copy): Likewise. (_pager_seqnos_memory_object_data_write): Likewise. (_pager_seqnos_memory_object_supply_completed): Likewise. --- libpager/notify-stubs.c | 13 ++++++++++++- libpager/priv.h | 3 ++- libpager/seqnos.c | 22 +++++++++++++++++++++- libpager/stubs.c | 12 ++++++++++-- 4 files changed, 45 insertions(+), 5 deletions(-) diff --git a/libpager/notify-stubs.c b/libpager/notify-stubs.c index 728163e4..aec56e35 100644 --- a/libpager/notify-stubs.c +++ b/libpager/notify-stubs.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1995 Free Software Foundation, Inc. + Copyright (C) 1995, 2011 Free Software Foundation, Inc. Written by Michael I. Bushnell. This file is part of the GNU Hurd. @@ -18,6 +18,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. */ +#include "priv.h" #include "notify_S.h" #include @@ -29,6 +30,8 @@ _pager_do_seqnos_mach_notify_port_deleted (mach_port_t notify mach_port_t name __attribute__ ((unused))) { + _pager_stubs_update_seqno (notify, seqno); + return 0; } @@ -40,6 +43,8 @@ _pager_do_seqnos_mach_notify_msg_accepted (mach_port_t notify mach_port_t name __attribute__ ((unused))) { + _pager_stubs_update_seqno (notify, seqno); + return 0; } @@ -51,6 +56,8 @@ _pager_do_seqnos_mach_notify_port_destroyed (mach_port_t notify mach_port_t name __attribute__ ((unused))) { + _pager_stubs_update_seqno (notify, seqno); + return 0; } @@ -60,6 +67,8 @@ _pager_do_seqnos_mach_notify_send_once (mach_port_t notify mach_port_seqno_t seqno __attribute__ ((unused))) { + _pager_stubs_update_seqno (notify, seqno); + return 0; } @@ -71,5 +80,7 @@ _pager_do_seqnos_mach_notify_dead_name (mach_port_t notify mach_port_t name __attribute__ ((unused))) { + _pager_stubs_update_seqno (notify, seqno); + return 0; } diff --git a/libpager/priv.h b/libpager/priv.h index 80afff1b..7a4fe6fe 100644 --- a/libpager/priv.h +++ b/libpager/priv.h @@ -1,5 +1,5 @@ /* Private data for pager library. - Copyright (C) 1994,95,96,97,99, 2000 Free Software Foundation, Inc. + Copyright (C) 1994-1997, 1999, 2000, 2011 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -133,6 +133,7 @@ struct port_class *_pager_class; void _pager_wait_for_seqno (struct pager *, int); void _pager_release_seqno (struct pager *, int); +void _pager_stubs_update_seqno (mach_port_t, int); void _pager_block_termination (struct pager *); void _pager_allow_termination (struct pager *); error_t _pager_pagemap_resize (struct pager *, vm_address_t); diff --git a/libpager/seqnos.c b/libpager/seqnos.c index 94cce93b..7afe0fbe 100644 --- a/libpager/seqnos.c +++ b/libpager/seqnos.c @@ -1,5 +1,5 @@ /* Sequence number synchronization routines for pager library - Copyright (C) 1994 Free Software Foundation + Copyright (C) 1994, 2011 Free Software Foundation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -47,3 +47,23 @@ _pager_release_seqno (struct pager *p, condition_broadcast (&p->wakeup); } } + + +/* Just update the seqno. */ +void +_pager_stubs_update_seqno (mach_port_t object, + int seqno) +{ + struct pager *p; + + p = ports_lookup_port (0, object, _pager_class); + if (p) + { + mutex_lock (&p->interlock); + _pager_wait_for_seqno (p, seqno); + _pager_release_seqno (p, seqno); + mutex_unlock (&p->interlock); + + ports_port_deref (p); + } +} diff --git a/libpager/stubs.c b/libpager/stubs.c index b455699e..44005378 100644 --- a/libpager/stubs.c +++ b/libpager/stubs.c @@ -1,5 +1,5 @@ /* Unused memory object interface stubs - Copyright (C) 1994 Free Software Foundation + Copyright (C) 1994, 2011 Free Software Foundation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -29,6 +29,9 @@ _pager_seqnos_memory_object_copy (mach_port_t old, mach_port_t new) { printf ("m_o_copy called\n"); + + _pager_stubs_update_seqno (old, seq); + return EOPNOTSUPP; } @@ -41,6 +44,9 @@ _pager_seqnos_memory_object_data_write (mach_port_t old, vm_size_t data_cnt) { printf ("m_o_data_write called\n"); + + _pager_stubs_update_seqno (old, seq); + return EOPNOTSUPP; } @@ -54,6 +60,8 @@ _pager_seqnos_memory_object_supply_completed (mach_port_t obj, vm_offset_t err_off) { printf ("m_o_supply_completed called\n"); + + _pager_stubs_update_seqno (obj, seq); + return EOPNOTSUPP; } - -- cgit v1.2.3 From ac67fbb6e2a503e27a579bdd92bfcd180f377ac4 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Thu, 24 Nov 2011 08:21:16 +0100 Subject: Further port sequence number cleanup. * libpager/priv.h (struct pager): Make seqno member of type mach_port_seqno_t. Change all users. * libpager/seqnos.c (_pager_stubs_update_seqno): Rename to _pager_update_seqno. Change all users. * libpager/demuxer.c (pager_demuxer): Make use of _pager_update_seqno. * libpager/notify-stubs.c: Remove unused attribute where no longer appropriate. --- libpager/demuxer.c | 20 ++++---------------- libpager/notify-stubs.c | 40 +++++++++++++++------------------------- libpager/priv.h | 8 ++++---- libpager/seqnos.c | 8 ++++---- libpager/stubs.c | 12 ++++++------ 5 files changed, 33 insertions(+), 55 deletions(-) diff --git a/libpager/demuxer.c b/libpager/demuxer.c index d6b99fc2..79c0ddc5 100644 --- a/libpager/demuxer.c +++ b/libpager/demuxer.c @@ -1,5 +1,5 @@ /* Demuxer for pager library - Copyright (C) 1994, 1995, 2002 Free Software Foundation + Copyright (C) 1994, 1995, 2002, 2011 Free Software Foundation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -33,20 +33,8 @@ pager_demuxer (mach_msg_header_t *inp, int result = _pager_seqnos_memory_object_server (inp, outp) || _pager_seqnos_notify_server (inp, outp); if (!result) - { - struct pager *p; - - p = ports_lookup_port (0, inp->msgh_local_port, _pager_class); - if (p) - { - /* Synchronize our bookkeeping of the port's seqno with - the one consumed by this bogus message. */ - mutex_lock (&p->interlock); - _pager_wait_for_seqno (p, inp->msgh_seqno); - _pager_release_seqno (p, inp->msgh_seqno); - mutex_unlock (&p->interlock); - ports_port_deref (p); - } - } + /* Synchronize our bookkeeping of the port's seqno with the one consumed by + this bogus message. */ + _pager_update_seqno (inp->msgh_local_port, inp->msgh_seqno); return result; } diff --git a/libpager/notify-stubs.c b/libpager/notify-stubs.c index aec56e35..2d791aac 100644 --- a/libpager/notify-stubs.c +++ b/libpager/notify-stubs.c @@ -23,64 +23,54 @@ #include error_t -_pager_do_seqnos_mach_notify_port_deleted (mach_port_t notify - __attribute__ ((unused)), - mach_port_seqno_t seqno - __attribute__ ((unused)), +_pager_do_seqnos_mach_notify_port_deleted (mach_port_t notify, + mach_port_seqno_t seqno, mach_port_t name __attribute__ ((unused))) { - _pager_stubs_update_seqno (notify, seqno); + _pager_update_seqno (notify, seqno); return 0; } error_t -_pager_do_seqnos_mach_notify_msg_accepted (mach_port_t notify - __attribute__ ((unused)), - mach_port_seqno_t seqno - __attribute__ ((unused)), +_pager_do_seqnos_mach_notify_msg_accepted (mach_port_t notify, + mach_port_seqno_t seqno, mach_port_t name __attribute__ ((unused))) { - _pager_stubs_update_seqno (notify, seqno); + _pager_update_seqno (notify, seqno); return 0; } error_t -_pager_do_seqnos_mach_notify_port_destroyed (mach_port_t notify - __attribute__ ((unused)), - mach_port_seqno_t seqno - __attribute__ ((unused)), +_pager_do_seqnos_mach_notify_port_destroyed (mach_port_t notify, + mach_port_seqno_t seqno, mach_port_t name __attribute__ ((unused))) { - _pager_stubs_update_seqno (notify, seqno); + _pager_update_seqno (notify, seqno); return 0; } error_t -_pager_do_seqnos_mach_notify_send_once (mach_port_t notify - __attribute__ ((unused)), - mach_port_seqno_t seqno - __attribute__ ((unused))) +_pager_do_seqnos_mach_notify_send_once (mach_port_t notify, + mach_port_seqno_t seqno) { - _pager_stubs_update_seqno (notify, seqno); + _pager_update_seqno (notify, seqno); return 0; } error_t -_pager_do_seqnos_mach_notify_dead_name (mach_port_t notify - __attribute__ ((unused)), - mach_port_seqno_t seqno - __attribute__ ((unused)), +_pager_do_seqnos_mach_notify_dead_name (mach_port_t notify, + mach_port_seqno_t seqno, mach_port_t name __attribute__ ((unused))) { - _pager_stubs_update_seqno (notify, seqno); + _pager_update_seqno (notify, seqno); return 0; } diff --git a/libpager/priv.h b/libpager/priv.h index 7a4fe6fe..586bccbf 100644 --- a/libpager/priv.h +++ b/libpager/priv.h @@ -50,7 +50,7 @@ struct pager memory_object_control_t memobjcntl; memory_object_name_t memobjname; - int seqno; + mach_port_seqno_t seqno; int noterm; /* number of threads blocking termination */ @@ -131,9 +131,9 @@ extern int _pager_page_errors[]; struct port_class *_pager_class; -void _pager_wait_for_seqno (struct pager *, int); -void _pager_release_seqno (struct pager *, int); -void _pager_stubs_update_seqno (mach_port_t, int); +void _pager_wait_for_seqno (struct pager *, mach_port_seqno_t); +void _pager_release_seqno (struct pager *, mach_port_seqno_t); +void _pager_update_seqno (mach_port_t, mach_port_seqno_t); void _pager_block_termination (struct pager *); void _pager_allow_termination (struct pager *); error_t _pager_pagemap_resize (struct pager *, vm_address_t); diff --git a/libpager/seqnos.c b/libpager/seqnos.c index 7afe0fbe..7d8bcba7 100644 --- a/libpager/seqnos.c +++ b/libpager/seqnos.c @@ -23,7 +23,7 @@ return. */ void _pager_wait_for_seqno (struct pager *p, - int seqno) + mach_port_seqno_t seqno) { while (seqno != p->seqno + 1) { @@ -37,7 +37,7 @@ _pager_wait_for_seqno (struct pager *p, _pager_wait_for_seqno) to be handled. */ void _pager_release_seqno (struct pager *p, - int seqno) + mach_port_seqno_t seqno) { assert (seqno == p->seqno + 1); p->seqno = seqno; @@ -51,8 +51,8 @@ _pager_release_seqno (struct pager *p, /* Just update the seqno. */ void -_pager_stubs_update_seqno (mach_port_t object, - int seqno) +_pager_update_seqno (mach_port_t object, + mach_port_seqno_t seqno) { struct pager *p; diff --git a/libpager/stubs.c b/libpager/stubs.c index 44005378..84782120 100644 --- a/libpager/stubs.c +++ b/libpager/stubs.c @@ -21,22 +21,22 @@ #include kern_return_t -_pager_seqnos_memory_object_copy (mach_port_t old, +_pager_seqnos_memory_object_copy (mach_port_t obj, mach_port_seqno_t seq, - memory_object_control_t old_ctl, + memory_object_control_t obj_ctl, vm_offset_t off, vm_size_t len, mach_port_t new) { printf ("m_o_copy called\n"); - _pager_stubs_update_seqno (old, seq); + _pager_update_seqno (obj, seq); return EOPNOTSUPP; } kern_return_t -_pager_seqnos_memory_object_data_write (mach_port_t old, +_pager_seqnos_memory_object_data_write (mach_port_t obj, mach_port_seqno_t seq, mach_port_t ctl, vm_offset_t off, @@ -45,7 +45,7 @@ _pager_seqnos_memory_object_data_write (mach_port_t old, { printf ("m_o_data_write called\n"); - _pager_stubs_update_seqno (old, seq); + _pager_update_seqno (obj, seq); return EOPNOTSUPP; } @@ -61,7 +61,7 @@ _pager_seqnos_memory_object_supply_completed (mach_port_t obj, { printf ("m_o_supply_completed called\n"); - _pager_stubs_update_seqno (obj, seq); + _pager_update_seqno (obj, seq); return EOPNOTSUPP; } -- cgit v1.2.3