Skip to content

Commit

Permalink
lio_listio should emit an event for each individual request in
Browse files Browse the repository at this point in the history
	addition to the global event.
	* sysdeps/pthread/lio_listio.c (lio_listio): Renamed to
	lio_listio_internal.  Remove mode parameter check.  Only set sigevent
	type ti SIGEV_NONE if LIO_NO_INDIVIDUAL_EVENT is set.
	(__lio_listio_21): New function.  Compatiblity version which sets
	LIO_NO_INDIVIDUAL_EVENT before calling lio_listio_internal.
	(__lio_listio_item_notify): New function.
	* sysdeps/pthread/lio_listio64.c: Define __lio_listio_21 and
	__lio_listio_item_notify macros.
	* sysdeps/pthread/Versions: New file.
	* rt/tst-aio2.c: Adjust test for new semantics of lio_listio.
	* include/aio.h: Define LIO_NO_INDIVIDUAL_EVENT.
	* Versions.def: Add GLIBC_2.4 for librt.

	* rt/Versions: Whitespace fix.
	* sysdeps/pthread/aio_misc.c: Likewise.
  • Loading branch information
Ulrich Drepper committed Jan 3, 2006
1 parent 1c50f6b commit 6d3aff2
Show file tree
Hide file tree
Showing 9 changed files with 117 additions and 28 deletions.
18 changes: 18 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
2006-01-03 Ulrich Drepper <drepper@redhat.com>

lio_listio should emit an event for each individual request in
addition to the global event.
* sysdeps/pthread/lio_listio.c (lio_listio): Renamed to
lio_listio_internal. Remove mode parameter check. Only set sigevent
type ti SIGEV_NONE if LIO_NO_INDIVIDUAL_EVENT is set.
(__lio_listio_21): New function. Compatiblity version which sets
LIO_NO_INDIVIDUAL_EVENT before calling lio_listio_internal.
(__lio_listio_item_notify): New function.
* sysdeps/pthread/lio_listio64.c: Define __lio_listio_21 and
__lio_listio_item_notify macros.
* sysdeps/pthread/Versions: New file.
* rt/tst-aio2.c: Adjust test for new semantics of lio_listio.
* include/aio.h: Define LIO_NO_INDIVIDUAL_EVENT.
* Versions.def: Add GLIBC_2.4 for librt.

* rt/Versions: Whitespace fix.
* sysdeps/pthread/aio_misc.c: Likewise.

* nscd/connections.c (nscd_init): Remove if block which should
have been removed as part of the -S option removal.

Expand Down
1 change: 1 addition & 0 deletions Versions.def
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ librt {
GLIBC_2.3
GLIBC_2.3.3
GLIBC_2.3.4
GLIBC_2.4
}
libutil {
GLIBC_2.0
Expand Down
8 changes: 7 additions & 1 deletion include/aio.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#ifndef _AIO_H
#include <rt/aio.h>

/* Now define the internal interfaces. */
/* Now define the internal interfaces. */
extern void __aio_init (__const struct aioinit *__init);

/* Flag to signal we need to be copmatible with glibc < 2.4 in
lio_listio and we do not issue events for each individual list
element. */
#define LIO_NO_INDIVIDUAL_EVENT 128

#endif
2 changes: 1 addition & 1 deletion rt/Versions
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ librt {
}
GLIBC_2.3.4 {
# m*
mq_open; mq_close; mq_unlink; mq_getattr; mq_setattr;
mq_open; mq_close; mq_unlink; mq_getattr; mq_setattr;
mq_notify; mq_send; mq_receive; mq_timedsend; mq_timedreceive;
}
}
25 changes: 20 additions & 5 deletions rt/tst-aio2.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Test for notification mechanism in lio_listio.
Copyright (C) 2000,02 Free Software Foundation, Inc.
Copyright (C) 2000, 2002, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 2000.
Expand All @@ -25,13 +25,19 @@
#include <unistd.h>
#include <errno.h>

int flag;

static pthread_barrier_t b;


static void
thrfct (sigval_t arg)
{
flag = 1;
int e = pthread_barrier_wait (&b);
if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
{
puts ("thread: barrier_wait failed");
exit (1);
}
}


Expand All @@ -53,6 +59,12 @@ do_test (int argc, char *argv[])

unlink (name);

if (pthread_barrier_init (&b, NULL, 2) != 0)
{
puts ("barrier_init failed");
return 1;
}

arr[0] = &cb;

cb.aio_fildes = fd;
Expand All @@ -77,9 +89,12 @@ do_test (int argc, char *argv[])
return 1;
}

if (flag != 0)
puts ("lio_listio returned");

int e = pthread_barrier_wait (&b);
if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
{
puts ("thread created, should not have happened");
puts ("barrier_wait failed");
return 1;
}

Expand Down
5 changes: 5 additions & 0 deletions sysdeps/pthread/Versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
librt {
GLIBC_2.4 {
lio_listio; lio_listio64;
}
}
5 changes: 2 additions & 3 deletions sysdeps/pthread/aio_misc.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Handle general operations.
Copyright (C) 1997, 1998, 1999, 2000, 2001, 2003, 2004
Copyright (C) 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2006
Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
Expand Down Expand Up @@ -46,8 +46,7 @@ __aio_create_helper_thread (pthread_t *threadp, void *(*tf) (void *), void *arg)

(void) pthread_attr_destroy (&attr);
return ret;
}

}
#endif

static void add_request_to_runlist (struct requestlist *newrequest);
Expand Down
77 changes: 60 additions & 17 deletions sysdeps/pthread/lio_listio.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Enqueue and list of read or write requests.
Copyright (C) 1997,1998,1999,2000,2001,2003,2005
Copyright (C) 1997,1998,1999,2000,2001,2003,2005,2006
Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
Expand Down Expand Up @@ -31,6 +31,9 @@
#define LIO_OPCODE_BASE 0
#endif

#include <shlib-compat.h>


/* We need this special structure to handle asynchronous I/O. */
struct async_waitlist
{
Expand All @@ -40,26 +43,29 @@ struct async_waitlist
};


int
lio_listio (mode, list, nent, sig)
int mode;
struct aiocb *const list[];
int nent;
struct sigevent *sig;
/* The code in glibc 2.1 to glibc 2.4 issued only one event when all
requests submitted with lio_listio finished. The existing practice
is to issue events for the individual requests as well. This is
what the new code does. */
#if SHLIB_COMPAT (librt, GLIBC_2_1, GLIBC_2_4)
# define LIO_MODE(mode) ((mode) & 127)
# define NO_INDIVIDUAL_EVENT_P(mode) ((mode) & 128)
#else
# define LIO_MODE(mode) mode
# define NO_INDIVIDUAL_EVENT_P(mode) 0
#endif


static int
lio_listio_internal (int mode, struct aiocb *const list[], int nent,
struct sigevent *sig)
{
struct sigevent defsigev;
struct requestlist *requests[nent];
int cnt;
volatile int total = 0;
int result = 0;

/* Check arguments. */
if (mode != LIO_WAIT && mode != LIO_NOWAIT)
{
__set_errno (EINVAL);
return -1;
}

if (sig == NULL)
{
defsigev.sigev_notify = SIGEV_NONE;
Expand All @@ -74,7 +80,9 @@ lio_listio (mode, list, nent, sig)
for (cnt = 0; cnt < nent; ++cnt)
if (list[cnt] != NULL && list[cnt]->aio_lio_opcode != LIO_NOP)
{
list[cnt]->aio_sigevent.sigev_notify = SIGEV_NONE;
if (NO_INDIVIDUAL_EVENT_P (mode))
list[cnt]->aio_sigevent.sigev_notify = SIGEV_NONE;

requests[cnt] = __aio_enqueue_request ((aiocb_union *) list[cnt],
(list[cnt]->aio_lio_opcode
| LIO_OPCODE_BASE));
Expand All @@ -100,7 +108,7 @@ lio_listio (mode, list, nent, sig)
locked forever. */
pthread_mutex_unlock (&__aio_requests_mutex);

if (mode == LIO_NOWAIT)
if (LIO_MODE (mode) == LIO_NOWAIT)
{
#ifdef BROKEN_THREAD_SIGNALS
__aio_notify_only (sig,
Expand All @@ -112,7 +120,7 @@ lio_listio (mode, list, nent, sig)

return result;
}
else if (mode == LIO_WAIT)
else if (LIO_MODE (mode) == LIO_WAIT)
{
pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
struct waitlist waitlist[nent];
Expand Down Expand Up @@ -202,3 +210,38 @@ lio_listio (mode, list, nent, sig)

return result;
}


#if SHLIB_COMPAT (librt, GLIBC_2_1, GLIBC_2_4)
int
attribute_compat_text_section
__lio_listio_21 (int mode, struct aiocb *const list[], int nent,
struct sigevent *sig)
{
/* Check arguments. */
if (mode != LIO_WAIT && mode != LIO_NOWAIT)
{
__set_errno (EINVAL);
return -1;
}

return lio_listio_internal (mode | LIO_NO_INDIVIDUAL_EVENT, list, nent, sig);
}
compat_symbol (librt, __lio_listio_21, lio_listio, GLIBC_2_1);
#endif


int
__lio_listio_item_notify (int mode, struct aiocb *const list[], int nent,
struct sigevent *sig)
{
/* Check arguments. */
if (mode != LIO_WAIT && mode != LIO_NOWAIT)
{
__set_errno (EINVAL);
return -1;
}

return lio_listio_internal (mode, list, nent, sig);
}
versioned_symbol (librt, __lio_listio_item_notify, lio_listio, GLIBC_2_4);
4 changes: 3 additions & 1 deletion sysdeps/pthread/lio_listio64.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Enqueue and list of read or write requests, 64bit offset version.
Copyright (C) 1997, 1998, 1999, 2003, 2005 Free Software Foundation, Inc.
Copyright (C) 1997,1998,1999,2003,2005,2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
Expand Down Expand Up @@ -27,6 +27,8 @@
#include <aio_misc.h>

#define lio_listio lio_listio64
#define __lio_listio_21 __lio_listio64_21
#define __lio_listio_item_notify __lio_listio64_item_notify
#define aiocb aiocb64
#define LIO_OPCODE_BASE 128
#include <lio_listio.c>

0 comments on commit 6d3aff2

Please sign in to comment.