Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OS-7991 port_get() and port_getn() implementation disagrees with documentation #225

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions usr/src/head/port.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@
* Copyright 2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Copyright 2019 Joyent, Inc.
*/

#ifndef _PORT_H
#define _PORT_H

#pragma ident "%Z%%M% %I% %E% SMI"

#include <sys/types.h>
#include <sys/port.h>

Expand All @@ -45,8 +46,9 @@ int port_associate(int, int, uintptr_t, int, void *);
int port_dissociate(int, int, uintptr_t);
int port_send(int, int, void *);
int port_sendn(int [], int [], uint_t, int, void *);
int port_get(int, port_event_t *, struct timespec *);
int port_getn(int, port_event_t [], uint_t, uint_t *, struct timespec *);
int port_get(int, port_event_t *, const struct timespec *);
int port_getn(int, port_event_t [], uint_t, uint_t *,
const struct timespec *);
int port_alert(int, int, int, void *);

#ifdef __cplusplus
Expand Down
7 changes: 5 additions & 2 deletions usr/src/lib/libc/port/gen/event_port.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Copyright 2019 Joyent, Inc.
*/

#include "lint.h"
#include <sys/types.h>
Expand Down Expand Up @@ -64,7 +67,7 @@ port_associate(int port, int source, uintptr_t object, int events, void *user)


int
port_get(int port, port_event_t *pe, struct timespec *to)
port_get(int port, port_event_t *pe, const struct timespec *to)
{
rval_t r;
if (to)
Expand All @@ -77,7 +80,7 @@ port_get(int port, port_event_t *pe, struct timespec *to)

int
port_getn(int port, port_event_t list[], uint_t max, uint_t *nget,
struct timespec *timeout)
const struct timespec *timeout)
{
rval_t r;
if (nget == NULL) {
Expand Down
16 changes: 15 additions & 1 deletion usr/src/uts/common/fs/portfs/port.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*/

/*
* Copyright (c) 2015 Joyent, Inc. All rights reserved.
* Copyright 2019 Joyent, Inc.
*/

#include <sys/types.h>
Expand Down Expand Up @@ -615,6 +615,20 @@ portfs(int opcode, uintptr_t a0, uintptr_t a1, uintptr_t a2, uintptr_t a3,
error = port_getn(pp, (port_event_t *)a1, 1,
(uint_t *)&nget, &port_timer);
} while (nget == 0 && error == 0 && port_timer.pgt_loop);

/*
* There are cases when a timeout is given to port_getn() where
* it returns no events but also no error, such as when events
* are available but can't be copied out, or when there are no
* events and the timeout is all zero.
*
* This isn't a problem in PORT_GETN as the number of retrieved
* events is always returned correctly, but in the case of
* PORT_GET we need to fix this up here and return ETIME as
* documented.
*/
if (nget == 0 && error == 0 && a4 != 0)
error = ETIME;
break;
}
case PORT_GETN:
Expand Down