+ Debugged.

This commit is contained in:
Jennifer Averett
1999-12-23 22:09:36 +00:00
parent 8f12d069bf
commit 7fbef78639
4 changed files with 126 additions and 84 deletions
+31 -16
View File
@@ -47,7 +47,10 @@ mqd_t mq_open(
int status;
Objects_Id the_mq_id;
POSIX_Message_queue_Control *the_mq;
Objects_Locations location;
_Thread_Disable_dispatch();
if ( oflag & O_CREAT ) {
va_start(arg, oflag);
mode = (mode_t) va_arg( arg, mode_t );
@@ -66,31 +69,37 @@ mqd_t mq_open(
if ( status ) {
if ( status == EINVAL ) { /* name -> ID translation failed */
if ( !(oflag & O_CREAT) ) { /* willing to create it? */
set_errno_and_return_minus_one( ENOENT );
return (mqd_t) -1;
}
/* we are willing to create it */
/*
* Unless provided a valid name that did not already exist
* and we are willing to create then it is an error.
*/
if ( !( status == ENOENT && (oflag & O_CREAT) ) ) {
_Thread_Enable_dispatch();
set_errno_and_return_minus_one_cast( status, mqd_t );
}
set_errno_and_return_minus_one( status ); /* some type of error */
return (mqd_t) -1;
} else { /* name -> ID translation succeeded */
/*
* Check for existence with creation.
*/
if ( (oflag & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL) ) {
set_errno_and_return_minus_one( EEXIST );
return (mqd_t) -1;
_Thread_Enable_dispatch();
set_errno_and_return_minus_one_cast( EEXIST, mqd_t );
}
/*
* XXX In this case we need to do an ID->pointer conversion to
* check the mode. This is probably a good place for a subroutine.
*/
the_mq = _POSIX_Message_queue_Get( the_mq_id, &location );
the_mq->open_count += 1;
return (mqd_t)&the_mq->Object.id;
_Thread_Enable_dispatch();
_Thread_Enable_dispatch();
return (mqd_t)the_mq->Object.id;
}
@@ -108,9 +117,15 @@ mqd_t mq_open(
&the_mq
);
/*
* errno was set by Create_support, so don't set it again.
*/
_Thread_Enable_dispatch();
if ( status == -1 )
return (mqd_t) -1;
return (mqd_t) &the_mq->Object.id;
return (mqd_t) the_mq->Object.id;
}
+32 -26
View File
@@ -42,34 +42,40 @@ int mq_unlink(
Objects_Id the_mq_id;
Objects_Locations location;
_Thread_Disable_dispatch();
status = _POSIX_Message_queue_Name_to_id( name, &the_mq_id );
if ( status != 0 )
if ( status != 0 ) {
_Thread_Enable_dispatch();
set_errno_and_return_minus_one( status );
the_mq = _POSIX_Message_queue_Get( the_mq_id, &location );
switch ( location ) {
case OBJECTS_ERROR:
set_errno_and_return_minus_one( EINVAL );
case OBJECTS_REMOTE:
_Thread_Dispatch();
return POSIX_MP_NOT_IMPLEMENTED();
set_errno_and_return_minus_one( EINVAL );
case OBJECTS_LOCAL:
#if defined(RTEMS_MULTIPROCESSING)
_Objects_MP_Close(
&_POSIX_Message_queue_Information,
the_mq->Object.id
);
#endif
the_mq->linked = FALSE;
_POSIX_Message_queue_Delete( the_mq );
_Thread_Enable_dispatch();
return 0;
}
/*
* Don't support unlinking a remote message queue.
*/
if ( !_Objects_Is_local_id(the_mq_id) ) {
_Thread_Enable_dispatch();
set_errno_and_return_minus_one( ENOSYS );
}
return POSIX_BOTTOM_REACHED();
the_mq = (POSIX_Message_queue_Control *) _Objects_Get_local_object(
&_POSIX_Message_queue_Information,
_Objects_Get_index( the_mq_id )
);
#if defined(RTEMS_MULTIPROCESSING)
if ( the_mq->process_shared == PTHREAD_PROCESS_SHARED ) {
_Objects_MP_Close( &_POSIX_Message_queue_Information, the_mq_id );
}
#endif
the_mq->linked = FALSE;
_POSIX_Message_queue_Namespace_remove( the_mq );
_POSIX_Message_queue_Delete( the_mq );
_Thread_Enable_dispatch();
return 0;
}
+31 -16
View File
@@ -47,7 +47,10 @@ mqd_t mq_open(
int status;
Objects_Id the_mq_id;
POSIX_Message_queue_Control *the_mq;
Objects_Locations location;
_Thread_Disable_dispatch();
if ( oflag & O_CREAT ) {
va_start(arg, oflag);
mode = (mode_t) va_arg( arg, mode_t );
@@ -66,31 +69,37 @@ mqd_t mq_open(
if ( status ) {
if ( status == EINVAL ) { /* name -> ID translation failed */
if ( !(oflag & O_CREAT) ) { /* willing to create it? */
set_errno_and_return_minus_one( ENOENT );
return (mqd_t) -1;
}
/* we are willing to create it */
/*
* Unless provided a valid name that did not already exist
* and we are willing to create then it is an error.
*/
if ( !( status == ENOENT && (oflag & O_CREAT) ) ) {
_Thread_Enable_dispatch();
set_errno_and_return_minus_one_cast( status, mqd_t );
}
set_errno_and_return_minus_one( status ); /* some type of error */
return (mqd_t) -1;
} else { /* name -> ID translation succeeded */
/*
* Check for existence with creation.
*/
if ( (oflag & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL) ) {
set_errno_and_return_minus_one( EEXIST );
return (mqd_t) -1;
_Thread_Enable_dispatch();
set_errno_and_return_minus_one_cast( EEXIST, mqd_t );
}
/*
* XXX In this case we need to do an ID->pointer conversion to
* check the mode. This is probably a good place for a subroutine.
*/
the_mq = _POSIX_Message_queue_Get( the_mq_id, &location );
the_mq->open_count += 1;
return (mqd_t)&the_mq->Object.id;
_Thread_Enable_dispatch();
_Thread_Enable_dispatch();
return (mqd_t)the_mq->Object.id;
}
@@ -108,9 +117,15 @@ mqd_t mq_open(
&the_mq
);
/*
* errno was set by Create_support, so don't set it again.
*/
_Thread_Enable_dispatch();
if ( status == -1 )
return (mqd_t) -1;
return (mqd_t) &the_mq->Object.id;
return (mqd_t) the_mq->Object.id;
}
+32 -26
View File
@@ -42,34 +42,40 @@ int mq_unlink(
Objects_Id the_mq_id;
Objects_Locations location;
_Thread_Disable_dispatch();
status = _POSIX_Message_queue_Name_to_id( name, &the_mq_id );
if ( status != 0 )
if ( status != 0 ) {
_Thread_Enable_dispatch();
set_errno_and_return_minus_one( status );
the_mq = _POSIX_Message_queue_Get( the_mq_id, &location );
switch ( location ) {
case OBJECTS_ERROR:
set_errno_and_return_minus_one( EINVAL );
case OBJECTS_REMOTE:
_Thread_Dispatch();
return POSIX_MP_NOT_IMPLEMENTED();
set_errno_and_return_minus_one( EINVAL );
case OBJECTS_LOCAL:
#if defined(RTEMS_MULTIPROCESSING)
_Objects_MP_Close(
&_POSIX_Message_queue_Information,
the_mq->Object.id
);
#endif
the_mq->linked = FALSE;
_POSIX_Message_queue_Delete( the_mq );
_Thread_Enable_dispatch();
return 0;
}
/*
* Don't support unlinking a remote message queue.
*/
if ( !_Objects_Is_local_id(the_mq_id) ) {
_Thread_Enable_dispatch();
set_errno_and_return_minus_one( ENOSYS );
}
return POSIX_BOTTOM_REACHED();
the_mq = (POSIX_Message_queue_Control *) _Objects_Get_local_object(
&_POSIX_Message_queue_Information,
_Objects_Get_index( the_mq_id )
);
#if defined(RTEMS_MULTIPROCESSING)
if ( the_mq->process_shared == PTHREAD_PROCESS_SHARED ) {
_Objects_MP_Close( &_POSIX_Message_queue_Information, the_mq_id );
}
#endif
the_mq->linked = FALSE;
_POSIX_Message_queue_Namespace_remove( the_mq );
_POSIX_Message_queue_Delete( the_mq );
_Thread_Enable_dispatch();
return 0;
}