/*
 * IPC_CONTROL_MSG_TYPE_TRANSFER_EVENT are events that we registered for
 * that have been sent by the data node.IPC_CONTROL_MSG_TYPE_TRANSFER_COMPLETE
 * comes from data nodes regardless of whether we asked for it or not.
 * See gridftp_hpss_dsi_ipc_control.c ipc_control_event_callback() for more
 * details.
 */
static void
transfer_control_ipc_msg(transfer_control_t * TransferControl,
/*                         int                  NodeIndex, */
                         int                  MsgType,
                         int                  MsgLen,
                         void               * Msg)
{
	ipc_control_transfer_event_t    * transfer_event    = NULL;
	ipc_control_transfer_complete_t * transfer_complete = NULL;

	GlobusGFSName(__func__);
	GlobusGFSHpssDebugEnter();

#ifdef NOT
	globus_assert(NodeIndex >= 0 && NodeIndex < TransferControl->DataNodeCount);
#endif /* NOT */

	switch (MsgType)
	{
	case IPC_CONTROL_MSG_TYPE_TRANSFER_EVENT:
/* Incoming ranges from data node(s). */
		transfer_event = (ipc_control_transfer_event_t *) Msg;
		break;

	case IPC_CONTROL_MSG_TYPE_TRANSFER_COMPLETE:
		transfer_complete = (ipc_control_transfer_complete_t *) Msg;

		transfer_control_data_complete(TransferControl, transfer_complete->Result);
#ifdef NOT
		globus_mutex_lock(&TransferControl->Lock);
		{
			/* Increase the thread count so cleanup doesn't happen before we exit. */
			TransferControl->ThreadCount++;

			/* Indicate that this node has completed. */
			TransferControl->DataNodes[0].Complete = GLOBUS_TRUE;
			TransferControl->DataNodes[0].Result = transfer_complete->Result;
			if (TransferControl->DataNodes[0].Result == GLOBUS_SUCCESS)
				TransferControl->DataNodes[0].Result = transfer_complete->Reply->result;

			/* Increment the completion count. */
			TransferControl->NodesDone++;
		}
		globus_mutex_unlock(&TransferControl->Lock);

		/* Update our state. */
		transfer_control_update_state(TransferControl);
#endif /* NOT */

		break;
	default:
		globus_assert(0);
	}
	GlobusGFSHpssDebugExit();
}
void
gridftp_register_write_callback(globus_gfs_operation_t   Operation,
                                globus_result_t          Result,
                                globus_byte_t          * Buffer,
                                globus_size_t            BytesWritten,
                                void                   * CallbackArg)
{
	gridftp_t * gridftp = NULL;

	GlobusGFSName(__func__);
	GlobusGFSHpssDebugEnter();

	/* Make sure we got our callback arg. */
	globus_assert(CallbackArg != NULL);
	/* Cast to our handle. */
	gridftp = (gridftp_t *) CallbackArg;

	/* Pass the buffer forward. */
	if (Result == GLOBUS_SUCCESS)
		gridftp->BufferPassFunc(gridftp->BufferPassArg, (char *)Buffer, 0, 0);

	/* Record any error we might have had. */
	gridftp_record_error(gridftp, Result);

	/* Register more writes. */
	gridftp_register_write(gridftp, GLOBUS_TRUE);

	/* Decrement the current op count. */
	gridftp_decrement_op_count(gridftp);

	GlobusGFSHpssDebugExit();
}
void
globus_xio_system_socket_destroy(
    globus_xio_system_socket_handle_t   handle)
{
    unsigned long                       flag = 0;
    GlobusXIOName(globus_xio_system_socket_destroy);
    
    GlobusXIOSystemDebugEnterFD(handle->socket);
    
    globus_assert(!handle->read_info && !handle->write_info);
    
    /* no need to ensure entry is still registered, as I always return true
     * in the callback and this is only place i unregister
     */
    globus_i_xio_win32_event_lock(handle->event_entry);
    
    GlobusXIOSystemDebugPrintf(
        GLOBUS_I_XIO_SYSTEM_DEBUG_INFO,
        ("[%s] Unregistering event handle=%lu for socket %ld\n",
            _xio_name, (unsigned long) handle->event, (long) handle->socket));
            
    globus_i_xio_win32_event_unregister(handle->event_entry);
    globus_i_xio_win32_event_unlock(handle->event_entry);
    
    WSAEventSelect(handle->socket, 0, 0);
    ioctlsocket(handle->socket, FIONBIO, &flag);
    WSACloseEvent(handle->event);
    win32_mutex_destroy(&handle->lock);
    
    GlobusXIOSystemDebugExitFD(handle->socket);
    globus_free(handle);
}
static
globus_bool_t
globus_l_gram_job_manager_staging_match(
    void *                              datum,
    void *                              arg)
{
    globus_gram_job_manager_staging_info_t *
                                        item;
    globus_gram_job_manager_staging_info_t *
                                        query;

    item = datum;
    query = arg;

    globus_assert(item->type == query->type);

    if((strcmp(item->evaled_from, query->evaled_from) == 0) &&
       (strcmp(item->evaled_to, query->evaled_to) == 0))
    {
        return GLOBUS_TRUE;
    }
    else
    {
        return GLOBUS_FALSE;
    }
}
/**
 * @brief Lock a recursive mutex
 * @ingroup globus_mutex
 *
 * @details
 *     The globus_rmutex_lock() function acquires the lock controlled by
 *     @a rmutex. This may be called multiple times in a single thread without
 *     causing deadlock, provided that a call to globus_rmutex_unlock() is
 *     called the same number of times as globus_rmutex_lock(). Once acquired,
 *     all other threads calling this function will be blocked until the
 *     mutex is completely unlocked.
 *
 * @param rmutex
 *     A pointer to the mutex to lock
 *
 * @return
 *     On success, globus_rmutex_init() increases the lock level for the
 *     mutex, blocks other threads trying to acquire the same mutex, and
 *     returns GLOBUS_SUCCESS; otherwise, it returns a non-zero error code.
 */
int
globus_rmutex_lock(
    globus_rmutex_t *                   rmutex)
{
    globus_thread_t                     thread_id;

    thread_id = globus_thread_self();

    globus_mutex_lock(&rmutex->mutex);
    {
        globus_assert(rmutex->level >= 0);

        if(rmutex->level > 0 &&
                !globus_thread_equal(rmutex->thread_id, thread_id))
        {
            rmutex->waiting++;
            do
            {
                globus_cond_wait(&rmutex->cond, &rmutex->mutex);
            } while(rmutex->level > 0);
            rmutex->waiting--;
        }

        rmutex->level++;
        rmutex->thread_id = thread_id;
    }
    globus_mutex_unlock(&rmutex->mutex);

    return 0;
}
/**
 * @brief Unlock a recursive mutex
 * @ingroup globus_mutex
 *
 * @details
 *     The globus_rmutex_unlock() function decrements the lock count for
 *     the lock pointed to by @a rmutex. If the lock count is reduced to
 *     zero, it also unblocks a thread which is trying to acquire the lock
 *     if there is one.
 *
 * @param rmutex
 *     Mutex to unlock
 *
 * @return GLOBUS_SUCCESS
 */
int
globus_rmutex_unlock(
    globus_rmutex_t *                   rmutex)
{
    globus_mutex_lock(&rmutex->mutex);
    {
        /* I don't fail here because this is being used with libtool and it
         * unlocks a mutex that was never locked
         */
        if(rmutex->level > 0)
        {
            globus_assert(
                globus_thread_equal(rmutex->thread_id, globus_thread_self()));

            rmutex->level--;
            if(rmutex->level == 0)
            {
                memset(&rmutex->thread_id,0,sizeof(rmutex->thread_id));
                if(rmutex->waiting)
                {
                    globus_cond_signal(&rmutex->cond);
                }
            }
        }
    }
    globus_mutex_unlock(&rmutex->mutex);

    return 0;
}
/*
 * All incoming messages.
 */
static void
transfer_control_msg_recv(void          * CallbackArg,
                          msg_comp_id_t   DstMsgCompID,
                          msg_comp_id_t   SrcMsgCompID,
                          int             MsgType,
                          int             MsgLen,
                          void          * Msg)
{
	transfer_control_t * transfer_control = (transfer_control_t *) CallbackArg;

	GlobusGFSName(__func__);
	GlobusGFSHpssDebugEnter();

	switch (SrcMsgCompID)
	{
	case MSG_COMP_ID_TRANSFER_DATA:
		transfer_control_transfer_data_msg(transfer_control, MsgType, MsgLen, Msg);
		break;
#ifdef REMOTE
	case MSG_COMP_ID_IPC_CONTROL:
		transfer_control_ipc_msg(transfer_control, /*NodeIndex,*/ MsgType, MsgLen, Msg);
		break;
#endif /* REMOTE */
	default:
		globus_assert(0);
	}

	GlobusGFSHpssDebugExit();
}
Exemplo n.º 8
0
static
void
gfork_l_child_error(
    gfork_i_lib_handle_t *              handle,
    globus_result_t                     in_result)
{
    globus_result_t                     result;

    switch(handle->state)
    {
    /* we are already doing it */
    case GFORK_STATE_CLOSING:
        break;

    case GFORK_STATE_OPEN:
        handle->error_obj = globus_error_get(in_result);
        result = globus_xio_register_close(
                     handle->write_xio, NULL,
                     gfork_l_child_write_close_cb, handle);
        if(result != GLOBUS_SUCCESS)
        {
            /* wtf ? */
        }
        handle->state = GFORK_STATE_CLOSING;

        break;

    default:
        globus_assert(0 && "Invalid state");
    }
}
static void
transfer_control_event_range_complete(void            * CallbackArg,
                                      globus_result_t   Result)
{
	globus_result_t      result           = GLOBUS_SUCCESS;
	transfer_control_t * transfer_control = NULL;
	transfer_control_complete_msg_t complete_msg;

	GlobusGFSName(__func__);
	GlobusGFSHpssDebugEnter();

	/* Cast to our handle. */
	transfer_control = (transfer_control_t *) CallbackArg;

	globus_mutex_lock(&transfer_control->Lock);
	{
		/* Save the error. */
		if (transfer_control->Result == GLOBUS_SUCCESS)
			transfer_control->Result = Result;

		/* If the data side has not reported in. */
		if (transfer_control->State == TRANSFER_CONTROL_TRANSFER_RUNNING)
		{
			/* Update our state. */
			transfer_control->State = TRANSFER_CONTROL_WAIT_FOR_DATA_COMPLETE;

			/* Tell the data side to shutdown. */
			if (Result != GLOBUS_SUCCESS)
				result = msg_send(transfer_control->MsgHandle,
				                  MSG_COMP_ID_TRANSFER_DATA,
				                  MSG_COMP_ID_TRANSFER_CONTROL,
				                  TRANSFER_CONTROL_MSG_TYPE_SHUTDOWN,
				                  0,
				                  NULL);
			goto unlock;
		}

		/* Update our state. */
		transfer_control->State = TRANSFER_CONTROL_COMPLETE;

		/* Prepare the completion message. */
		complete_msg.Result = transfer_control->Result;

		/* Send the message. */
		result = msg_send(transfer_control->MsgHandle,
		                  MSG_COMP_ID_ANY,
		                  MSG_COMP_ID_TRANSFER_CONTROL,
		                  TRANSFER_CONTROL_MSG_TYPE_COMPLETE,
		                  sizeof(transfer_control_complete_msg_t),
		                  &complete_msg);

		/* XXX */
		globus_assert(result == GLOBUS_SUCCESS);
	}
unlock:
	globus_mutex_unlock(&transfer_control->Lock);

	GlobusGFSHpssDebugExit();
}
globus_result_t
list_insert_before(list_t * List,
                   void   * NewData,
                   void   * ExistingData)
{
	entry_t         * new_entry      = NULL;
	entry_t         * existing_entry = NULL;
	globus_result_t   result         = GLOBUS_SUCCESS;

	GlobusGFSName(__func__);
	GlobusGFSHpssDebugEnter();

	/* Allocate the new entry. */
	new_entry = (entry_t *) globus_calloc(1, sizeof(entry_t));
	if (new_entry == NULL)
	{
		result = GlobusGFSErrorMemory("entry_t");
		goto cleanup;
	}

	/* Save the new entry's data. */
	new_entry->Data = NewData;

	/* Now put it on the list. */
	globus_mutex_lock(&List->Lock);
	{
		/* Find the existing entry. */
		for (existing_entry  = List->Head; 
		     existing_entry != NULL; 
		     existing_entry  = existing_entry->Next)
		{
			if (existing_entry->Data == ExistingData)
				break;
		}

		/* Make sure we found something. */
		globus_assert(existing_entry != NULL);

		/* Insert before the existing entry. */
		new_entry->Prev      = existing_entry->Prev;
		existing_entry->Prev = new_entry;
		new_entry->Next      = existing_entry;
		if (new_entry->Prev == NULL)
			List->Head = new_entry;
		else
			new_entry->Prev->Next = new_entry;
	}
	globus_mutex_unlock(&List->Lock);

cleanup:
	if (result != GLOBUS_SUCCESS)
	{
		GlobusGFSHpssDebugExitWithError();
		return result;
	}

	GlobusGFSHpssDebugExit();
	return SUCCESS;
}
static void
data_destroy_cb(
    void *                                  user_data_handle,
    void *                                  user_arg)
{
    fprintf(stdout, "data_destroy_cb()\n");
    globus_assert(user_data_handle == USER_DATA_HANDLE);
}
Exemplo n.º 12
0
/*
 * globus_l_module_mutex_unlock()
 */
static void
globus_l_module_mutex_unlock(
	globus_l_module_mutex_t *		mutex)
{
    globus_mutex_lock(&mutex->mutex);
    {
	globus_assert(mutex->level > 0);
	globus_assert( globus_thread_equal( mutex->thread_id, globus_thread_self() ) );

	mutex->level--;
	if (mutex->level == 0)
	{
	    globus_cond_signal(&mutex->cond);
	}
    }
    globus_mutex_unlock(&mutex->mutex);
}
Exemplo n.º 13
0
int
globus_l_args_validate( globus_args_option_descriptor_t *   option, 
			int                                 start_argc,
			char **                             argv,
			char ***                            values,
			const char *                        oneline_usage,
			char **                             msg_storage  )
{
    int           rc;
    int           i;
    void *        p;
    char *        argp;
    char *        validation_error;

    *values = globus_l_args_malloc(char*, option->arity);
    globus_assert(*values);
    
    rc = GLOBUS_SUCCESS;

    for (i=0; !rc && i<option->arity; i++)
    {
	argp = argv[start_argc+1+i];
	if (option->tests && option->tests[i] )
	{
	    p = GLOBUS_NULL;
	    if ( option->test_parms && option->test_parms[i] )
		p = option->test_parms[i];

	    validation_error = GLOBUS_NULL;
	    rc = option->tests[i]( argp,
				   p,
				   &validation_error );

	    /* API defines non-zero return as an error */
	    if (rc)
	    {
		globus_l_args_create_error_msg( msg_storage,
						start_argc+1+i,
						argp,
						validation_error,
						oneline_usage   );
		continue;
	    }
	} /* if */

	(*values)[i] = argp;

    }   /* for */

    if (rc)
    {
	free(*values);
	rc = GLOBUS_FAILURE;
    }

    return rc;
}
Exemplo n.º 14
0
static
void
data_callback(
    globus_xio_handle_t                 handle,
    globus_result_t                     result,
    globus_byte_t *                     buffer,
    globus_size_t                       len,
    globus_size_t                       nbytes,
    globus_xio_data_descriptor_t        data_desc,
    void *                              user_arg)
{
    globus_l_timeout_info_t *           info = user_arg;

    globus_mutex_lock(&lock);
    if (result != GLOBUS_SUCCESS)
    {
        if (info->state == info->timeout_state &&
            info->expect_timeout &&
            result_is_timeout(result))
        {
            /* hit expected result */
            info->expect_timeout = GLOBUS_FALSE;

            result = GLOBUS_SUCCESS;
        }

        info->state = GLOBUS_XIO_OPERATION_TYPE_CLOSE;
    }
    else
    {
        globus_assert(info->state == GLOBUS_XIO_OPERATION_TYPE_READ ||
                      info->state == GLOBUS_XIO_OPERATION_TYPE_WRITE);

        if (info->state == GLOBUS_XIO_OPERATION_TYPE_READ &&
            info->server != NULL)
        {
            info->state = GLOBUS_XIO_OPERATION_TYPE_WRITE;
        }
        else if (info->state == GLOBUS_XIO_OPERATION_TYPE_WRITE &&
                 info->server != NULL)
        {
            info->state = GLOBUS_XIO_OPERATION_TYPE_CLOSE;
        }
        else if (info->state == GLOBUS_XIO_OPERATION_TYPE_WRITE)
        {
            info->state = GLOBUS_XIO_OPERATION_TYPE_READ;
        }
        else
        {
            info->state = GLOBUS_XIO_OPERATION_TYPE_WRITE;
        }
    }
    info->result = result;
    globus_mutex_unlock(&lock);
    state_machine(info);
}
Exemplo n.º 15
0
static
void
gfork_l_child_read_body_cb(
    globus_xio_handle_t                 xio_handle,
    globus_result_t                     result,
    globus_byte_t *                     buffer,
    globus_size_t                       len,
    globus_size_t                       nbytes,
    globus_xio_data_descriptor_t        data_desc,
    void *                              user_arg)
{
    gfork_i_lib_handle_t *            handle;

    handle = (gfork_i_lib_handle_t *) user_arg;

    if(result != GLOBUS_SUCCESS)
    {
        goto error_incoming;
    }

    globus_assert(nbytes == handle->header.size);

    handle->incoming_cb(
        handle,
        handle->user_arg,
        handle->header.from_pid,
        buffer,
        nbytes);

    result = globus_xio_register_read(
                 handle->read_xio,
                 (globus_byte_t *)&handle->header,
                 sizeof(gfork_i_msg_header_t),
                 sizeof(gfork_i_msg_header_t),
                 NULL,
                 gfork_l_child_read_header_cb,
                 handle);
    if(result != GLOBUS_SUCCESS)
    {
        goto error_post;
    }

    return;

error_post:
error_incoming:

    free(buffer);
    globus_mutex_lock(&handle->mutex);
    {
        gfork_l_child_error(handle, result);
    }
    globus_mutex_unlock(&handle->mutex);
}
void
test_res(
    globus_result_t                         res)
{
    if(res == GLOBUS_SUCCESS)
    {
        return;
    }

    fprintf(stderr, "ERROR: %s\n", globus_error_print_chain(
        globus_error_peek(res)));

    globus_assert(0);
}
void
test_res(
    globus_result_t                         res)
{
    if(res == GLOBUS_SUCCESS)
    {
        return;
    }

    fprintf(stderr, "ERROR: %s\n", globus_object_printable_to_string(
        globus_error_get(res)));

    globus_assert(0);
}
/*
 * The initial offset of any transfer (stream or extended, restart, 
 * partial or full) is always 0.
 */
static void
gridftp_register_read_callback(globus_gfs_operation_t   Operation,
                               globus_result_t          Result,
                               globus_byte_t *          Buffer,
                               globus_size_t            BytesRead,
                               globus_off_t             FileOffset,
                               globus_bool_t            Eof,
                               void                   * CallbackArg)
{
	gridftp_t * gridftp = NULL;

	GlobusGFSName(__func__);
	GlobusGFSHpssDebugEnter();

	/* Make sure we got our callback arg. */
	globus_assert(CallbackArg != NULL);
	/* Cast to our handle. */
	gridftp = (gridftp_t *) CallbackArg;

	/* Pass the buffer forward. */
	if (Result == GLOBUS_SUCCESS && BytesRead > 0)
	{
		/* Mark the buffer as ready. */
		buffer_set_buffer_ready(gridftp->BufferHandle,
		                        gridftp->PrivateBufferID,
		                        (char *)Buffer,
		                        FileOffset,
		                        BytesRead);

		/* Now pass the buffer forward. */
		gridftp->BufferPassFunc(gridftp->BufferPassArg, 
		                       (char*)Buffer, 
		                       FileOffset,
		                       BytesRead);
	}

	/* Record any error we might have had. */
	gridftp_record_error(gridftp, Result);

	/* Record eof. */
	gridftp_record_eof(gridftp, Eof);

	/* Fire off more reads. */
	gridftp_register_read(gridftp, GLOBUS_TRUE);

	/* Decrement the current op count. */
	gridftp_decrement_op_count(gridftp);

	GlobusGFSHpssDebugExit();
}
Exemplo n.º 19
0
int
globus_l_args_create_error_msg( char **        error_msg,
				int            current_argc,
				char *         current_argv,
				char *         error_string,
				const char *   oneline_usage )
{
    char *      my_error_string;
    char *      p;
    int         usage_len;
    int         len;


#define error_format    _GCSL("\nError, argument #%d (%s) : %s\n\nSyntax : ")
#define error_epilogue  _GCSL("\n\nUse -help to display full usage.\n")

    my_error_string = (error_string) ? error_string : _GCSL("(no error message)");

    len = strlen(error_format)
        + strlen(current_argv)
        + strlen(my_error_string)
        + strlen(oneline_usage)
        + strlen(error_epilogue)
	+ 10;

    p = globus_l_args_malloc( char, len );
    globus_assert( p );
    globus_libc_sprintf( p,
			 error_format, 
			 current_argc, 
			 current_argv,
			 my_error_string  );

    usage_len = strlen( oneline_usage );

    len = strlen(p);
    strncpy( &p[len], oneline_usage, usage_len );
    sprintf( &p[len+usage_len], "%s", error_epilogue );

    if (error_msg)
	*error_msg = p;
    else
    {
	globus_libc_fprintf( stderr, "%s", p );
	free(p);
    }

    return GLOBUS_SUCCESS;
}
Exemplo n.º 20
0
void
test_res(
    globus_result_t                         res,
    int                                     line)
{
    if(res == GLOBUS_SUCCESS)
    {
        return;
    }

    fprintf(stderr, "ERROR @ %d: %s\n", line, globus_error_print_chain(
        globus_error_get(res)));

    globus_assert(0);
}
Exemplo n.º 21
0
static void
open_bounce_cb(
    globus_xio_operation_t              op,
    globus_result_t                     result,
    void *                              user_arg)
{
    bounce_info_t *                     info;

    info = (bounce_info_t *) user_arg;
    /* verify open callback isn't called twice */
    globus_assert(info->handle->open_cb == GLOBUS_FALSE);
    info->handle->open_cb = GLOBUS_TRUE;

    bounce_cb(op, result, user_arg);
}
static void
transfer_control_event_data_complete(transfer_control_t * TransferControl,
                                     globus_result_t      Result)
{
	globus_result_t                 result = GLOBUS_SUCCESS;
	transfer_control_complete_msg_t complete_msg;

	GlobusGFSName(__func__);
	GlobusGFSHpssDebugEnter();

	globus_mutex_lock(&TransferControl->Lock);
	{
		/* Save the error. */
		if (TransferControl->Result == GLOBUS_SUCCESS)
			TransferControl->Result = Result;

		/* If PIO is still running... */
		if (TransferControl->State == TRANSFER_CONTROL_TRANSFER_RUNNING)
		{
			/* Update the state. */
			TransferControl->State = TRANSFER_CONTROL_WAIT_FOR_PIO_COMPLETE;

			goto unlock;
		}

		/* Update the state. */
		TransferControl->State = TRANSFER_CONTROL_COMPLETE;

		/* Prepare the completion message. */
		complete_msg.Result = TransferControl->Result;

		/* Send the message. */
		result = msg_send(TransferControl->MsgHandle,
		                  MSG_COMP_ID_ANY,
		                  MSG_COMP_ID_TRANSFER_CONTROL,
		                  TRANSFER_CONTROL_MSG_TYPE_COMPLETE,
		                  sizeof(transfer_control_complete_msg_t),
		                  &complete_msg);

		/* XXX */
		globus_assert(result == GLOBUS_SUCCESS);
	}
unlock:
	globus_mutex_unlock(&TransferControl->Lock);

	GlobusGFSHpssDebugExit();
}
Exemplo n.º 23
0
int
globus_l_args_add_instance( globus_fifo_t *                     fifo,
			    globus_args_option_descriptor_t *   option,
			    char **                             values )
{
    globus_args_option_instance_t *  t;

    t = globus_l_args_malloc( globus_args_option_instance_t , 1 );
    globus_assert( t );
    t->id_number = option->id_number;
    t->arity = option->arity;
    t->values = values;

    globus_fifo_enqueue( fifo, t );

    return GLOBUS_SUCCESS;
}
Exemplo n.º 24
0
static globus_result_t
globus_l_xio_bounce_close(
    void *                              driver_handle,
    void *                              attr,
    globus_xio_operation_t              op)
{
    bounce_info_t *                     info;
    globus_result_t                     res;
    GlobusXIOName(globus_l_xio_bounce_close);

    GlobusXIOTestDebugInternalEnter();

    info = (bounce_info_t *)
                globus_malloc(sizeof(bounce_info_t));
    memset(info, '\0', sizeof(bounce_info_t));
    info->next_op = TEST_READ;
    info->bounce_count = 0;
    info->max_count = MAX_COUNT;
    info->start_op = TEST_CLOSE;
    info->wait_for = 1024;
    info->iovec = &info->tmp_iovec;
    info->iovec->iov_base = (globus_byte_t *)0x100;
    info->iovec->iov_len = 1024;
    info->iovec_count = 1;

    info->handle = driver_handle;

    /* verify close isn't called twice */
    globus_assert(info->handle->closed_iface == GLOBUS_FALSE);

    info->handle->closed_iface = GLOBUS_TRUE;

    res = test_bounce_next_op(info, op);
    if(res != GLOBUS_SUCCESS)
    {
        bounce_handle_destroy(info->handle);
        goto err;
    }
    GlobusXIOTestDebugInternalExit();
    return GLOBUS_SUCCESS;    

  err:

    GlobusXIOTestDebugInternalExitWithError();
    return res;
}
void
list_move_to_end(list_t * List,
                 void   * Data)
{
	entry_t * entry  = NULL;

	GlobusGFSName(__func__);
	GlobusGFSHpssDebugEnter();

	/* Now put it on the list. */
	globus_mutex_lock(&List->Lock);
	{
		/* Find the existing entry. */
		for (entry = List->Head; entry != NULL; entry = entry->Next)
		{
			if (entry->Data == Data)
				break;
		}

		/* Make sure we found something. */
		globus_assert(entry != NULL);

		/* Remove it from the list. */
		if (entry->Prev != NULL)
			entry->Prev->Next = entry->Next;
		else
			List->Head = entry->Next;

		if (entry->Next != NULL)
			entry->Next->Prev = entry->Prev;
		else
			List->Tail = entry->Prev;

		/* Now insert on the tail. */
		entry->Next = NULL;
		entry->Prev = List->Tail;
		if (List->Tail != NULL)
			List->Tail->Next = entry;
		List->Tail = entry;
		if (List->Head == NULL)
			List->Head = entry;
	}
	globus_mutex_unlock(&List->Lock);

	GlobusGFSHpssDebugExit();
}
Exemplo n.º 26
0
void
globus_args_option_instance_list_free( globus_list_t **  list )
{
    globus_args_option_instance_t  *   t;
    
    while(!globus_list_empty(*list))
    {
        t = (globus_args_option_instance_t *)
            globus_list_remove(list, *list);
	globus_assert(t);
	if (t->values)
	    free( t->values );
	globus_free(t);
        
    }
    
    return;
}
static void
globus_gs_cmd_site(
    globus_gridftp_server_control_op_t      op,
    const char *                            full_command,
    char **                                 cmd_a,
    int                                     argc,
    void *                                  user_arg)
{
    if(strcmp(cmd_a[1], "MINE") == 0)
    {
        globus_gsc_959_finished_command(
            op, "200 successful sire interception\r\n");
    }
    else
    {
        globus_assert(0);
    }
}
static void
transfer_control_event_data_ready(transfer_control_t * TransferControl)
{
	globus_result_t result = GLOBUS_SUCCESS;

	GlobusGFSName(__func__);
	GlobusGFSHpssDebugEnter();


	/*
	 * If there is nothing to transfer...
	 */
	if (range_list_empty(TransferControl->TransferRangeList))
	{
		/* Update our state. */
		TransferControl->State = TRANSFER_CONTROL_WAIT_FOR_DATA_COMPLETE;

		/* Tell the data side to shutdown. */
		result = msg_send(TransferControl->MsgHandle,
		                  MSG_COMP_ID_TRANSFER_DATA,
		                  MSG_COMP_ID_TRANSFER_CONTROL,
		                  TRANSFER_CONTROL_MSG_TYPE_SHUTDOWN,
		                  0,
		                  NULL);

		/* XXX */
		globus_assert(result == GLOBUS_SUCCESS);

		goto cleanup;
	}

	/* Update our state. */
	TransferControl->State = TRANSFER_CONTROL_TRANSFER_RUNNING;

	/* Tell PIO to perform the transfer. */
	pio_control_transfer_ranges(TransferControl->PioControl,
	                            1,
	                            TransferControl->StripeBlockSize,
	                            TransferControl->TransferRangeList,
	                            transfer_control_event_range_complete,
	                            TransferControl);
cleanup:
	GlobusGFSHpssDebugExit();
}
Exemplo n.º 29
0
/*
 * globus_l_module_mutex_lock()
 */
static void
globus_l_module_mutex_lock(
	globus_l_module_mutex_t *		mutex)
{
    globus_mutex_lock(&mutex->mutex);
    {
	globus_assert(mutex->level >= 0);
	while (mutex->level > 0
		   && !globus_thread_equal( mutex->thread_id, globus_thread_self()) )
	{
	    globus_cond_wait(&mutex->cond, &mutex->mutex);
	}

	mutex->level++;
	mutex->thread_id = globus_thread_self();
	
    }
    globus_mutex_unlock(&mutex->mutex);
}
void
globus_i_gass_transfer_keyvalue_replace(
    globus_list_t **				list,
    char *					key,
    char *					value)
{
    globus_list_t *				tmp;
    globus_gass_transfer_keyvalue_t *	kv;

    tmp = globus_list_search_pred(
	    *list,
	    globus_i_gass_transfer_keyvalue_search_pred, 
	    (void *) key);

    globus_assert(tmp != GLOBUS_NULL);
    kv = (globus_gass_transfer_keyvalue_t *)
	globus_list_first(tmp);
    kv->value = value;
}