コード例 #1
0
void
session_destroy_session_info(globus_gfs_session_info_t * SessionInfo)
{
	GlobusGFSName(__func__);
	GlobusGFSHpssDebugEnter();

	if (SessionInfo->username != NULL)
		globus_free(SessionInfo->username);
	if (SessionInfo->password != NULL)
		globus_free(SessionInfo->password);
	if (SessionInfo->subject != NULL)
		globus_free(SessionInfo->subject);
	if (SessionInfo->cookie != NULL)
		globus_free(SessionInfo->cookie);
	if (SessionInfo->host_id != NULL)
		globus_free(SessionInfo->host_id);

	SessionInfo->username = NULL;
	SessionInfo->password = NULL;
	SessionInfo->subject  = NULL;
	SessionInfo->cookie   = NULL;
	SessionInfo->host_id  = NULL;

	GlobusGFSHpssDebugExit();
}
コード例 #2
0
/*
 * Translates Family to the id. Family can be the name or the id.
 * Returns SESSION_NO_FAMILY_ID if Family is not found.
 */
int
session_get_family_id(session_handle_t * SessionHandle, char * Family)
{
	int    family_id   = SESSION_NO_FAMILY_ID;
	char * family_name = NULL;

	GlobusGFSName(__func__);
	GlobusGFSHpssDebugEnter();

	/* Try to get it by name. */
	family_id = config_get_family_id(SessionHandle->ConfigHandle, Family);
	if (family_id != CONFIG_NO_FAMILY_ID)
		goto cleanup;

	/* Convert the id. */
	family_id = atoi(Family);

	/* Lookup the name to be sure it exists. */
	family_name = config_get_family_name(SessionHandle->ConfigHandle, family_id);
	if (family_name == NULL)
		family_id = SESSION_NO_COS_ID;

cleanup:
	GlobusGFSHpssDebugExit();

	return family_id;
}
コード例 #3
0
static
int
globus_gfs_acl_test_init(
    void **                             out_handle,
    globus_gfs_acl_info_t *             acl_info,
    globus_gfs_acl_handle_t             acl_handle,
    globus_result_t *                   out_res)
{
    GlobusGFSName(globus_gfs_acl_test_init);
    GlobusGFSDebugEnter();

    if(1 || (acl_info->subject && 
        strcmp(acl_info->subject, "subject you allow") == 0))
    {
        *out_res = GLOBUS_SUCCESS;
    }
    else
    {
        *out_res = GlobusGFSErrorGeneric("No soup for you.");
    }        

    globus_gfs_acl_authorized_finished(acl_handle, *out_res);

    GlobusGFSDebugExit();
    return GLOBUS_GFS_ACL_WOULD_BLOCK;
}
コード例 #4
0
static
void 
globus_l_gfs_sigint(
    void *                              user_arg)
{
    GlobusGFSName(globus_l_gfs_sigint);
    GlobusGFSDebugEnter();

    globus_mutex_lock(&globus_l_gfs_mutex);
    {
        if(globus_l_gfs_sigint_caught)
        {
            globus_l_gfs_server_active = 0;
        }

        globus_l_gfs_sigint_caught = GLOBUS_TRUE;
        globus_l_gfs_terminated = GLOBUS_TRUE;

        if(!globus_l_gfs_server_active)
        {
            globus_cond_signal(&globus_l_gfs_cond);
        }
        else
        {
            globus_libc_printf("Embedded server stopping.\n");
            globus_gridftp_server_embed_stop(globus_l_gfs_server_handle);
        }
    }
    globus_mutex_unlock(&globus_l_gfs_mutex);

    GlobusGFSDebugExit();
}
void
transfer_control_destroy(transfer_control_t * TransferControl)
{
	GlobusGFSName(__func__);
	GlobusGFSHpssDebugEnter();

	if (TransferControl != NULL)
	{
		/* Unregister to receive messages. */
		msg_unregister(TransferControl->MsgHandle, TransferControl->MsgRegisterID);

		/* Destroy the PIO control handle. */
		pio_control_destroy(TransferControl->PioControl);

/*
 * Temp workaround to make sure the thread that called us isn't still 
 * holding this lock.
 */
globus_mutex_lock(&TransferControl->Lock);
globus_mutex_unlock(&TransferControl->Lock);
		/* Dellocate the lock. */
		globus_mutex_destroy(&TransferControl->Lock);

		/* Destroy the transfer range list. */
		range_list_destroy(TransferControl->TransferRangeList);

		/* Deallocate our handle. */
		globus_free(TransferControl);
	}

    GlobusGFSHpssDebugExit();
}
コード例 #6
0
static
int
globus_gfs_acl_test_authorize(
    void *                              out_handle,
    const char *                        action,
    const char *                        object,
    globus_gfs_acl_info_t *             acl_info,
    globus_gfs_acl_handle_t             acl_handle,
    globus_result_t *                   out_res)
{
    GlobusGFSName(globus_gfs_acl_test_authorize);
    GlobusGFSDebugEnter();

    if(1 || strncmp(object, "/path/you/allow", 5) == 0)
    {
        *out_res = GLOBUS_SUCCESS;
    }
    else
    {
        *out_res = GlobusGFSErrorGeneric("No soup for you.");
    }
    
    globus_gfs_acl_authorized_finished(acl_handle, *out_res);

    GlobusGFSDebugExit();
    return GLOBUS_GFS_ACL_WOULD_BLOCK;
}
/*
 * 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();
}
コード例 #8
0
static void
globus_gfs_acl_test_destroy(
    void *                              out_handle)
{
    GlobusGFSName(globus_gfs_acl_test_destroy);
    GlobusGFSDebugEnter();
}
コード例 #9
0
void
gridftp_stop(gridftp_t * GridFTP)
{
	GlobusGFSName(__func__);
	GlobusGFSHpssDebugEnter();

	if (GridFTP == NULL)
		goto cleanup;

	globus_mutex_lock(&GridFTP->Lock);
	{
		/* Indicate full stop. */
		GridFTP->Stop = GLOBUS_TRUE;

		/* Wait for all ops to complete. */
		while (GridFTP->OpCount != 0)
		{
			globus_cond_wait(&GridFTP->Cond, &GridFTP->Lock);
		}
	}
	globus_mutex_unlock(&GridFTP->Lock);

cleanup:
	GlobusGFSHpssDebugExit();
}
コード例 #10
0
globus_result_t
list_init(list_t ** List)
{
	globus_result_t result = GLOBUS_SUCCESS;

	GlobusGFSName(__func__);
	GlobusGFSHpssDebugEnter();

	/* Allocate the list. */
	*List = (list_t *) globus_calloc(1, sizeof(list_t));
	if (*List == NULL)
	{
		result = GlobusGFSErrorMemory("list_t");
		goto cleanup;
	}

	/* Initialize the list. */
	globus_mutex_init(&(*List)->Lock, NULL);

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

	GlobusGFSHpssDebugExit();
	return SUCCESS;
}
コード例 #11
0
/*
 * Translates Cos to the id. Cos can be the name or the id.
 * Returns SESSION_NO_COS_ID if cos is not found.
 */
int
session_get_cos_id(session_handle_t * SessionHandle, char * Cos)
{
	int    cos_id   = SESSION_NO_COS_ID;
	char * cos_name = NULL;

	GlobusGFSName(__func__);
	GlobusGFSHpssDebugEnter();

	/* Try to get it by name. */
	cos_id = config_get_cos_id(SessionHandle->ConfigHandle, Cos);
	if (cos_id != CONFIG_NO_COS_ID)
		goto cleanup;

	/* Convert the id. */
	cos_id = atoi(Cos);

	/* Lookup the name to be sure it exists. */
	cos_name = config_get_cos_name(SessionHandle->ConfigHandle, cos_id);
	if (cos_name == NULL)
		cos_id = SESSION_NO_COS_ID;

cleanup:
	GlobusGFSHpssDebugExit();

	return cos_id;
}
コード例 #12
0
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();
}
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();
}
コード例 #14
0
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;
}
コード例 #15
0
int
session_pref_get_cos_id(session_handle_t * SessionHandle)
{
	GlobusGFSName(session_pref_get_cos_id);
	GlobusGFSHpssDebugEnter();
	GlobusGFSHpssDebugExit();
	return SessionHandle->Pref.CosID;
}
コード例 #16
0
/*
 * A copy of the pointer to our session_info is returned;
 * nothing is dup'ed.
 */
globus_gfs_session_info_t *
session_get_session_info(session_handle_t * SessionHandle)
{
	GlobusGFSName(__func__);
	GlobusGFSHpssDebugEnter();
	GlobusGFSHpssDebugExit();

	return &SessionHandle->SessionInfo;
}
コード例 #17
0
int
session_pref_get_family_id(session_handle_t * SessionHandle)
{
	GlobusGFSName(__func__);
	GlobusGFSHpssDebugEnter();
	GlobusGFSHpssDebugExit();

	return SessionHandle->Pref.FamilyID;
}
/*
 * 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();
}
/*
 * Special single-node transfer completion path.
 * XXX move this to a message.
 */
void
transfer_control_data_complete(transfer_control_t * TransferControl,
                               globus_result_t      Result)
{
	GlobusGFSName(__func__);
	GlobusGFSHpssDebugEnter();

	transfer_control_event_data_complete(TransferControl, Result);

	GlobusGFSHpssDebugExit();
}
コード例 #20
0
void
session_pref_set_family_id(session_handle_t * SessionHandle,
                           int                FamilyID)
{
	GlobusGFSName(__func__);
	GlobusGFSHpssDebugEnter();

	/* Save the family id. */
	SessionHandle->Pref.FamilyID = FamilyID;

	GlobusGFSHpssDebugExit();
}
コード例 #21
0
void
list_iterate(list_t         * List,
             iterate_func_t   SearchFunc,
             void           * CallbackArg)
{
	entry_t      * entry         = NULL;
	entry_t      * next_entry    = NULL;
	list_iterate_t iterate_value = 0;

	GlobusGFSName(__func__);
	GlobusGFSHpssDebugEnter();

	globus_mutex_lock(&List->Lock);
	{
		entry = List->Head;
		while (entry != NULL)
		{
			iterate_value = SearchFunc(entry->Data, CallbackArg);

			if (iterate_value & LIST_ITERATE_REMOVE)
			{
/*
* Remove the entry 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;

				/* Save the next entry. */
				next_entry = entry->Next;

				/* Deallocate the entry. */
				globus_free(entry);

				/* Now use the next entry. */
				entry = next_entry;
			} else
				entry = entry->Next;

			if (iterate_value & LIST_ITERATE_DONE)
				break;
		}
	}
	globus_mutex_unlock(&List->Lock);

	GlobusGFSHpssDebugExit();
}
コード例 #22
0
void
session_pref_set_cos_id(session_handle_t * SessionHandle,
                        int                CosID)
{
	GlobusGFSName(__func__);
	GlobusGFSHpssDebugEnter();

	/* Save the cos id. */
	SessionHandle->Pref.CosID = CosID;

	GlobusGFSHpssDebugExit();
}
コード例 #23
0
globus_result_t
stat_populate(char              * Name,
              int                 Type,
              int                 LinkCount,
              uint64_t            Size,
              char              * Owner,
              char              * ModTime,
              globus_gfs_stat_t * GFSStat)
{
	GlobusGFSName(stat_populate);

	memset(GFSStat, 0, sizeof(globus_gfs_stat_t));

	GFSStat->mode  = Type | S_IRWXU;
	GFSStat->nlink = LinkCount;
// XXX Inodes not supported
	GFSStat->ino   = 0xDEADBEEF;
// XXX UIDs not supported
//	XXX GFSStat->uid   = HpssStat->st_uid;
	GFSStat->gid   = 0; // Groups not supported
	GFSStat->dev   = 0;
	GFSStat->size  = Size;
	GFSStat->name  = globus_libc_strdup(Name);

	if (!ModTime)
	{
		GFSStat->atime = 0;
		GFSStat->mtime = 0;
		GFSStat->ctime = 0;
	} else
	{
		struct tm t;
		memset(&t, 0, sizeof(t));

		int ret = sscanf(ModTime, "%d-%d-%dT%d:%d:%d.", &t.tm_year,
		                                                &t.tm_mon,
		                                                &t.tm_mday,
		                                                &t.tm_hour,
		                                                &t.tm_min,
		                                                &t.tm_sec);
		if (ret != 6)
			return GlobusGFSErrorGeneric("Invalid time string");

		t.tm_year -= 1900;
		time_t time_of_day = mktime(&t);
		GFSStat->atime = time_of_day;
		GFSStat->mtime = time_of_day;
		GFSStat->ctime = time_of_day;
	}

	return GLOBUS_SUCCESS;
}
コード例 #24
0
void
gridftp_set_buffer_pass_func(gridftp_t              * GridFTP,
                              gridftp_buffer_pass_t   BufferPassFunc,
                              void                  * BufferPassArg)
{
	GlobusGFSName(__func__);
	GlobusGFSHpssDebugEnter();

	GridFTP->BufferPassFunc = BufferPassFunc;
	GridFTP->BufferPassArg  = BufferPassArg;

	GlobusGFSHpssDebugExit();
}
コード例 #25
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();
}
コード例 #26
0
static int
osg_activate(void)
{
    GlobusGFSName(osg_activate);
    globus_result_t result = GLOBUS_SUCCESS;

    memset(&osg_dsi_iface, '\0', sizeof(globus_gfs_storage_iface_t));

    char * dsi_name = getenv("OSG_EXTENSIONS_OVERRIDE_DSI");
    dsi_name = dsi_name ? dsi_name : "file";

    // Code adapted from globus_i_gfs_data.c in Globus Toolkit.
    void *new_dsi = (globus_gfs_storage_iface_t *) globus_extension_lookup(
        &osg_dsi_handle, GLOBUS_GFS_DSI_REGISTRY, dsi_name);
    if (new_dsi == NULL)
    {
        char module_name[1024];
        snprintf(module_name, 1024, "globus_gridftp_server_%s", dsi_name);
        module_name[1023] = '\0';
        result = globus_extension_activate(module_name);
        if (result != GLOBUS_SUCCESS)
        {
            result = GlobusGFSErrorWrapFailed("DSI activation", result);
            return result;
        }
    }
    new_dsi = (globus_gfs_storage_iface_t *) globus_extension_lookup(
        &osg_dsi_handle, GLOBUS_GFS_DSI_REGISTRY, dsi_name);
    if(new_dsi == NULL)
    {
        GlobusGFSErrorGenericStr(result,
            ("DSI '%s' is not available in the module.", dsi_name));
        return result;
    }

    memcpy(&osg_dsi_iface, new_dsi, sizeof(globus_gfs_storage_iface_t));
    original_command_function = osg_dsi_iface.command_func;
    original_init_function = osg_dsi_iface.init_func;
    osg_dsi_iface.command_func = osg_command;
    osg_dsi_iface.init_func = osg_extensions_init;

    globus_extension_registry_add(
        GLOBUS_GFS_DSI_REGISTRY,
        "osg",
        GlobusExtensionMyModule(globus_gridftp_server_osg),
        &osg_dsi_iface);
    
    return result;
}
static globus_result_t
transfer_control_common_init(transfer_control_msg_type_t    OpType,
                             msg_handle_t                *  MsgHandle,
                             transfer_control_t          ** TransferControl)
{
	globus_result_t result = GLOBUS_SUCCESS;

	GlobusGFSName(__func__);
	GlobusGFSHpssDebugEnter();

	/* Allocate the handle. */
	*TransferControl = (transfer_control_t *) globus_calloc(1, sizeof(transfer_control_t));
	if (*TransferControl == NULL)
	{
		result = GlobusGFSErrorMemory("transfer_control_t");
		goto cleanup;
	}

	/* Initialize the entries. */
	globus_mutex_init(&(*TransferControl)->Lock, NULL);
	(*TransferControl)->OpType        = OpType;
	(*TransferControl)->MsgHandle     = MsgHandle;
	(*TransferControl)->State         = TRANSFER_CONTROL_WAIT_FOR_DATA_READY;
	(*TransferControl)->MsgRegisterID = MSG_REGISTER_ID_NONE;

	/* Intialize the range list. Fill it later. */
	result = range_list_init(&(*TransferControl)->TransferRangeList);
	if (result != GLOBUS_SUCCESS)
		goto cleanup;

	/* Register to receive messages. */
	result = msg_register(MsgHandle,
	                      MSG_COMP_ID_IPC_CONTROL,
	                      MSG_COMP_ID_TRANSFER_CONTROL,
	                      transfer_control_msg_recv,
	                      *TransferControl,
	                      &(*TransferControl)->MsgRegisterID);

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

    GlobusGFSHpssDebugExit();
    return GLOBUS_SUCCESS;
}
コード例 #28
0
/*
 * This is the basic (minimal) initialization, used at the start of
 * all sessions.
 */
globus_result_t
session_init(globus_gfs_session_info_t *  SessionInfo,
             session_handle_t          ** SessionHandle)
{
	globus_result_t result = GLOBUS_SUCCESS;

    GlobusGFSName(__func__);
    GlobusGFSHpssDebugEnter();

	/* Allocate our session handle. */
	*SessionHandle = (session_handle_t *) globus_calloc(1, sizeof(session_handle_t));
	if (*SessionHandle == NULL)
	{
		result = GlobusGFSErrorMemory("session handle");
		goto cleanup;
	}

	/*
	 * Copy out the session info.
	 */
	result = session_copy_session_info(SessionInfo, &(*SessionHandle)->SessionInfo);
	if (result != GLOBUS_SUCCESS)
		goto cleanup;

	/* Indicate that no authentication has occurred. */
	(*SessionHandle)->Authenticated = GLOBUS_FALSE;

	/*
	 * Initialize the preferences.
	 */
	(*SessionHandle)->Pref.CosID    = SESSION_NO_COS_ID;
	(*SessionHandle)->Pref.FamilyID = SESSION_NO_FAMILY_ID;

cleanup:
	if (result != GLOBUS_SUCCESS)
	{
		/* Destroy the session handle. */
		session_destroy(*SessionHandle);
		/* Release our handle */
		*SessionHandle = NULL;

		GlobusGFSHpssDebugExitWithError();
		return result;
	}

	GlobusGFSHpssDebugExit();
	return GLOBUS_SUCCESS;
}
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();
}
コード例 #30
0
static
void
globus_l_gfs_signal_init()
{
    GlobusGFSName(globus_l_gfs_signal_init);
    GlobusGFSDebugEnter();
    
#   ifdef SIGINT
    globus_callback_register_signal_handler(
        SIGINT,
        GLOBUS_TRUE,
        globus_l_gfs_sigint,
        NULL);
#   endif

    GlobusGFSDebugExit();
}