示例#1
0
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axis2_conf_ctx_set_root_dir(
    axis2_conf_ctx_t * conf_ctx,
    const axutil_env_t * env,
    const axis2_char_t * path)
{
    axutil_thread_mutex_lock(conf_ctx->mutex);
    if(conf_ctx->root_dir)
    {
        AXIS2_FREE(env->allocator, conf_ctx->root_dir);
        conf_ctx->root_dir = NULL;
    }

    if(path)
    {
        conf_ctx->root_dir = axutil_strdup(env, path);
        if(!(conf_ctx->root_dir))
        {
            AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
            axutil_thread_mutex_unlock(conf_ctx->mutex);
            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory");
            return AXIS2_FAILURE;
        }
    }
    axutil_thread_mutex_unlock(conf_ctx->mutex);
    return AXIS2_SUCCESS;
}
示例#2
0
AXIS2_EXTERN void AXIS2_CALL
axutil_log_impl_write_to_file(
    axutil_log_t *log,
    axutil_thread_mutex_t *mutex,
    axutil_log_levels_t level,
    const axis2_char_t *file,
    const int line,
    const axis2_char_t *value)
{
    const char *level_str = "";
    axutil_log_impl_t *log_impl = AXUTIL_INTF_TO_IMPL(log);
    FILE *fd = NULL;

    /**
       * print all critical and error logs irrespective of log->level setting
      */

    switch (level)
    {
    case AXIS2_LOG_LEVEL_CRITICAL:
        level_str = "[critical] ";
        break;
    case AXIS2_LOG_LEVEL_ERROR:
        level_str = "[error] ";
        break;
    case AXIS2_LOG_LEVEL_WARNING:
        level_str = "[warning] ";
        break;
    case AXIS2_LOG_LEVEL_INFO:
        level_str = "[info] ";
        break;
    case AXIS2_LOG_LEVEL_DEBUG:
        level_str = "[debug] ";
        break;
    case AXIS2_LOG_LEVEL_TRACE:
        level_str = "[...TRACE...] ";
        break;
    case AXIS2_LOG_LEVEL_USER:
        break;
    }
    axutil_thread_mutex_lock(mutex);

    axutil_log_impl_rotate(log);
    fd = log_impl->stream;
   
    if (fd)
    {
        if (file)
            fprintf(fd, "[%s] %s%s(%d) %s\n", axutil_log_impl_get_time_str(),
                level_str, file, line, value);
        else
            fprintf(fd, "[%s] %s %s\n", axutil_log_impl_get_time_str(), level_str,
                value);
        fflush(fd);
    }
    axutil_thread_mutex_unlock(mutex);
}
示例#3
0
文件: counter.c 项目: AdrianRys/wsf
void AXIS2_CALL
service_admin_counter_increment (
    service_admin_counter_t *counter,
    const axutil_env_t *env,
    axis2_msg_ctx_t *msg_ctx)
{
    axutil_thread_mutex_lock(counter->mutex);
    counter->count++;
    axutil_thread_mutex_unlock(counter->mutex);
}
示例#4
0
AXIS2_EXTERN axis2_transport_receiver_t *AXIS2_CALL
axis2_udp_receiver_create(
    const axutil_env_t * env,
    const axis2_char_t * repo,
    const int port,
	axis2_char_t *multicast_group)
{
	axis2_udp_receiver_impl_t *receiver = NULL;

	receiver = (axis2_udp_receiver_impl_t *) AXIS2_MALLOC(env->allocator, sizeof(axis2_udp_receiver_impl_t));
	if (!receiver)
	{
		AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
		return NULL;
	}
	receiver->is_multicast = AXIS2_FALSE;
	receiver->conf_ctx = NULL;
	receiver->conf_ctx_private = NULL;
	receiver->port = port;
	receiver->udp_receiver.ops = &udp_transport_recvr_ops;
	receiver->multicast_group = multicast_group; 
	receiver->socket = AXIS2_INVALID_SOCKET;
	receiver->send_socket = AXIS2_INVALID_SOCKET;
	receiver->owns_socket = AXIS2_TRUE;
	receiver->max_packet_size = AXIS2_UDP_PACKET_MAX_SIZE;
	if (multicast_group)
	{
		receiver->is_multicast = AXIS2_TRUE;
	}
	receiver->mutex = axutil_thread_mutex_create(env->allocator,
                                                 AXIS2_THREAD_MUTEX_DEFAULT);
	/* 
	 * We are creating the receiver in two instances. When we create the receiver from the server 
	 * we create the conf context. If we are creating the receiver while creating the conf we are 
	 * not creating the conf as conf is already there.
	 */
	if (repo)
	{
		receiver->conf_ctx_private = axis2_build_conf_ctx(env, repo);
		if (!receiver->conf_ctx_private)
		{
			AXIS2_LOG_ERROR (env->log, AXIS2_LOG_SI, 
                             "unable to create private configuration context for repo path %s", repo);
            axis2_udp_receiver_free((axis2_transport_receiver_t *) receiver,
                                   env);
            return NULL;
		}
		receiver->conf_ctx = receiver->conf_ctx_private;
	}
	axutil_thread_mutex_lock(receiver->mutex);
	return &(receiver->udp_receiver);
}
示例#5
0
axis2_bool_t AXIS2_CALL
axis2_udp_receiver_is_running(
    axis2_transport_receiver_t * tr_receiver,
    const axutil_env_t * env)
{
	axis2_bool_t running = AXIS2_FALSE;
	axis2_udp_receiver_impl_t *receiver = NULL;
	receiver = AXIS2_INTF_TO_IMPL(tr_receiver);	
	axutil_thread_mutex_lock(receiver->mutex);
	running = !receiver->stop;
	axutil_thread_mutex_unlock(receiver->mutex);
	return running;
}
示例#6
0
AXIS2_EXTERN const axis2_char_t *AXIS2_CALL
axis2_conf_ctx_get_root_dir(
    const axis2_conf_ctx_t * conf_ctx,
    const axutil_env_t * env)
{
    axis2_char_t *rv = NULL;
    (void)env;
    /* Do we need to lock here? - damitha */
    axutil_thread_mutex_lock(conf_ctx->mutex);
    rv = conf_ctx->root_dir;
    axutil_thread_mutex_unlock(conf_ctx->mutex);
    return rv;
}
示例#7
0
AXIS2_EXTERN axutil_property_t *AXIS2_CALL
axis2_conf_ctx_get_property(
    const axis2_conf_ctx_t * conf_ctx,
    const axutil_env_t * env,
    const axis2_char_t * key)
{
    axutil_property_t* property = NULL;
    AXIS2_PARAM_CHECK(env->error, conf_ctx, NULL);
    AXIS2_PARAM_CHECK(env->error, key, NULL);

    axutil_thread_mutex_lock(conf_ctx->mutex);
    property = axis2_ctx_get_property(conf_ctx->base, env, key);
    axutil_thread_mutex_unlock(conf_ctx->mutex);

    return property;
}
示例#8
0
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axis2_conf_ctx_register_svc_grp_ctx(
    axis2_conf_ctx_t * conf_ctx,
    const axutil_env_t * env,
    const axis2_char_t * svc_grp_id,
    axis2_svc_grp_ctx_t * svc_grp_ctx)
{
    (void)env;
    axutil_thread_mutex_lock(conf_ctx->mutex);
    if(conf_ctx->svc_grp_ctx_map)
    {
        axutil_hash_set(conf_ctx->svc_grp_ctx_map, svc_grp_id, AXIS2_HASH_KEY_STRING, svc_grp_ctx);
    }
    axutil_thread_mutex_unlock(conf_ctx->mutex);
    return AXIS2_SUCCESS;
}
示例#9
0
AXIS2_EXTERN axis2_svc_grp_ctx_t *AXIS2_CALL
axis2_conf_ctx_get_svc_grp_ctx(
    const axis2_conf_ctx_t * conf_ctx,
    const axutil_env_t * env,
    const axis2_char_t * svc_grp_id)
{
    (void)env;
    axis2_svc_grp_ctx_t *rv = NULL;
    axutil_thread_mutex_lock(conf_ctx->mutex);
    if(conf_ctx->svc_grp_ctx_map)
    {
        rv = (axis2_svc_grp_ctx_t *)axutil_hash_get(conf_ctx->svc_grp_ctx_map, svc_grp_id,
            AXIS2_HASH_KEY_STRING);
    }
    axutil_thread_mutex_unlock(conf_ctx->mutex);
    return rv;
}
示例#10
0
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axis2_conf_ctx_set_property(
    axis2_conf_ctx_t *conf_ctx,
    const axutil_env_t * env,
    const axis2_char_t * key,
    axutil_property_t * value)
{
    axis2_status_t status = AXIS2_FAILURE;
    AXIS2_PARAM_CHECK(env->error, conf_ctx, AXIS2_FAILURE);
    AXIS2_PARAM_CHECK(env->error, key, AXIS2_FAILURE);
    AXIS2_PARAM_CHECK(env->error, value, AXIS2_FAILURE);

    axutil_thread_mutex_lock(conf_ctx->mutex);
    status = axis2_ctx_set_property(conf_ctx->base, env, key, value);
    axutil_thread_mutex_unlock(conf_ctx->mutex);

    return status;
}
示例#11
0
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axis2_conf_ctx_init(
    axis2_conf_ctx_t * conf_ctx,
    const axutil_env_t * env,
    axis2_conf_t * conf)
{
    axutil_hash_index_t *hi = NULL;
    void *ctx = NULL;

    axutil_thread_mutex_lock(conf_ctx->mutex);
    conf_ctx->conf = conf;

    for(hi = axutil_hash_first(conf_ctx->op_ctx_map, env); hi; hi = axutil_hash_next(env, hi))
    {
        axutil_hash_this(hi, NULL, NULL, &ctx);
        if(ctx)
        {
            axis2_op_ctx_t *op_ctx = (axis2_op_ctx_t *)ctx;
            axis2_op_ctx_init(op_ctx, env, conf);
        }
    }

    for(hi = axutil_hash_first(conf_ctx->svc_ctx_map, env); hi; hi = axutil_hash_next(env, hi))
    {
        axutil_hash_this(hi, NULL, NULL, &ctx);
        if(ctx)
        {
            axis2_svc_ctx_t *svc_ctx = (axis2_svc_ctx_t *)ctx;
            axis2_svc_ctx_init(svc_ctx, env, conf);
        }
    }

    for(hi = axutil_hash_first(conf_ctx->svc_grp_ctx_map, env); hi; hi = axutil_hash_next(env, hi))
    {
        axutil_hash_this(hi, NULL, NULL, &ctx);
        if(ctx)
        {
            axis2_svc_grp_ctx_t *svc_grp_ctx = (axis2_svc_grp_ctx_t *)ctx;
            axis2_svc_grp_ctx_init(svc_grp_ctx, env, conf);
        }
    }
    axutil_thread_mutex_unlock(conf_ctx->mutex);
    return AXIS2_SUCCESS;
}
示例#12
0
AXIS2_EXTERN axis2_op_ctx_t *AXIS2_CALL
axis2_conf_ctx_get_op_ctx(
    const axis2_conf_ctx_t * conf_ctx,
    const axutil_env_t * env,
    const axis2_char_t * message_id)
{
    axis2_op_ctx_t *rv = NULL;

    AXIS2_PARAM_CHECK(env->error, message_id, NULL);

    axutil_thread_mutex_lock(conf_ctx->mutex);
    if(conf_ctx->op_ctx_map)
    {
        rv = (axis2_op_ctx_t *)axutil_hash_get(conf_ctx->op_ctx_map, message_id,
            AXIS2_HASH_KEY_STRING);
    }
    axutil_thread_mutex_unlock(conf_ctx->mutex);
    return rv;
}
示例#13
0
AXIS2_EXTERN axutil_log_t *AXIS2_CALL
axutil_log_create_default(
    axutil_allocator_t *allocator)
{
    axutil_log_impl_t *log_impl;

    if (!allocator)
        return NULL;

    log_impl = (axutil_log_impl_t *) AXIS2_MALLOC(allocator,
                   sizeof(axutil_log_impl_t));

    if (!log_impl)
        return NULL;

    log_impl->mutex =
        axutil_thread_mutex_create(allocator, AXIS2_THREAD_MUTEX_DEFAULT);

    if (!log_impl->mutex)
    {
        fprintf(stderr, "cannot create log mutex \n");
        return NULL;
    }

    axutil_thread_mutex_lock(log_impl->mutex);
    log_impl->file_name = NULL;
    log_impl->log.size = AXUTIL_LOG_FILE_SIZE;
    log_impl->stream = stderr;
    axutil_thread_mutex_unlock(log_impl->mutex);
    /* by default, log is enabled */
    log_impl->log.enabled = 1;
    log_impl->log.level = AXIS2_LOG_LEVEL_DEBUG;

    log_impl->log.ops = &axutil_log_ops_var;

    return &(log_impl->log);
}
示例#14
0
static axis2_status_t AXIS2_CALL
axis2_msg_recv_load_and_init_svc_impl(
    axis2_msg_recv_t *msg_recv,
    const axutil_env_t *env,
    struct axis2_svc *svc)
{
    axutil_param_t *impl_info_param = NULL;
    void *impl_class = NULL;

    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);

    if(!svc)
    {
        return AXIS2_FAILURE;
    }

    impl_class = axis2_svc_get_impl_class(svc, env);
    if(impl_class)
    {
        return AXIS2_SUCCESS;
    }
    /* When we load the DLL we have to make sure that only one thread will load it */
    axutil_thread_mutex_lock(axis2_svc_get_mutex(svc, env));
    /* If more than one thread tries to acquires the lock, first thread loads the DLL.
     Others should not load the DLL */
    impl_class = axis2_svc_get_impl_class(svc, env);
    if(impl_class)
    {
        axutil_thread_mutex_unlock(axis2_svc_get_mutex(svc, env));
        return AXIS2_SUCCESS;
    }
    impl_info_param = axis2_svc_get_param(svc, env, AXIS2_SERVICE_CLASS);
    if(!impl_info_param)
    {
        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_STATE_SVC, AXIS2_FAILURE);
        axutil_thread_mutex_unlock(axis2_svc_get_mutex(svc, env));
        return AXIS2_FAILURE;
    }

    axutil_allocator_switch_to_global_pool(env->allocator);

    axutil_class_loader_init(env);

    impl_class = axutil_class_loader_create_dll(env, impl_info_param);
    AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "loading the services from msg_recv_load_and_init_svc");

    if(impl_class)
    {
        axis2_svc_skeleton_t *skel = (axis2_svc_skeleton_t *)impl_class;
        axis2_conf_t *conf = NULL;
        conf = axis2_conf_ctx_get_conf(msg_recv->conf_ctx, env);
        if (skel->ops->init)
        {
            AXIS2_SVC_SKELETON_INIT(skel, env);
        }
        if (skel->ops->init_with_conf)
        {
            AXIS2_SVC_SKELETON_INIT_WITH_CONF(skel, env, conf);
        }
    }

    axis2_svc_set_impl_class(svc, env, impl_class);

    axutil_allocator_switch_to_local_pool(env->allocator);
    axutil_thread_mutex_unlock(axis2_svc_get_mutex(svc, env));
    return AXIS2_SUCCESS;
}
示例#15
0
AXIS2_EXPORT axis2_svc_skeleton_t *AXIS2_CALL
axis2_msg_recv_make_new_svc_obj(
    axis2_msg_recv_t * msg_recv,
    const axutil_env_t * env,
    struct axis2_msg_ctx * msg_ctx)
{
    struct axis2_svc *svc = NULL;
    struct axis2_op_ctx *op_ctx = NULL;
    struct axis2_svc_ctx *svc_ctx = NULL;
    axutil_param_t *impl_info_param = NULL;
    void *impl_class = NULL;

    AXIS2_ENV_CHECK(env, NULL);
    AXIS2_PARAM_CHECK(env->error, msg_ctx, NULL);

    op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env);
    svc_ctx = axis2_op_ctx_get_parent(op_ctx, env);
    svc = axis2_svc_ctx_get_svc(svc_ctx, env);
    if(!svc)
    {
        return NULL;
    }

    impl_class = axis2_svc_get_impl_class(svc, env);
    if(impl_class)
    {
        return impl_class;
    }
    else
    {
        /* When we load the DLL we have to make sure that only one thread will load it */
        axutil_thread_mutex_lock(axis2_svc_get_mutex(svc, env));
        /* If more than one thread tries to acquires the lock, first thread loads the DLL.
         Others should not load the DLL */
        impl_class = axis2_svc_get_impl_class(svc, env);
        if(impl_class)
        {
            axutil_thread_mutex_unlock(axis2_svc_get_mutex(svc, env));
            return impl_class;
        }
        impl_info_param = axis2_svc_get_param(svc, env, AXIS2_SERVICE_CLASS);
        if(!impl_info_param)
        {
            AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_STATE_SVC, AXIS2_FAILURE);
            axutil_thread_mutex_unlock(axis2_svc_get_mutex(svc, env));
            return NULL;
        }

        axutil_allocator_switch_to_global_pool(env->allocator);

        axutil_class_loader_init(env);

        impl_class = axutil_class_loader_create_dll(env, impl_info_param);

        if(impl_class)
        {
            AXIS2_SVC_SKELETON_INIT((axis2_svc_skeleton_t *)impl_class, env);
        }

        axis2_svc_set_impl_class(svc, env, impl_class);

        axutil_allocator_switch_to_local_pool(env->allocator);
        axutil_thread_mutex_unlock(axis2_svc_get_mutex(svc, env));
        return impl_class;
	(void)msg_recv;
    }
}
示例#16
0
AXIS2_EXTERN axutil_log_t *AXIS2_CALL
axutil_log_create(
    axutil_allocator_t *allocator,
    axutil_log_ops_t *ops,
    const axis2_char_t *stream_name)
{
    axutil_log_impl_t *log_impl;
    axis2_char_t *path_home;
    axis2_char_t log_file_name[AXUTIL_LOG_FILE_NAME_SIZE];
    axis2_char_t log_dir[AXUTIL_LOG_FILE_NAME_SIZE];
    axis2_char_t tmp_filename[AXUTIL_LOG_FILE_NAME_SIZE];

    if (!allocator)
        return NULL;

    log_impl = (axutil_log_impl_t *) AXIS2_MALLOC(allocator,
                   sizeof(axutil_log_impl_t));

    if (!log_impl)
        return NULL;

    log_impl->mutex =
        axutil_thread_mutex_create(allocator, AXIS2_THREAD_MUTEX_DEFAULT);

    if (!log_impl->mutex)
    {
        fprintf(stderr, "cannot create log mutex \n");
        return NULL;
    }

#ifndef WIN32
    signal(SIGXFSZ, SIG_IGN);
#endif

    /* default log file is axis2.log */
    if (stream_name)
        AXIS2_SNPRINTF(tmp_filename, AXUTIL_LOG_FILE_NAME_SIZE, "%s", stream_name);
    else
        AXIS2_SNPRINTF(tmp_filename, AXUTIL_LOG_FILE_NAME_SIZE, "%s", "axis2.log");

    /* we write all logs to AXIS2C_HOME/logs if it is set otherwise
     * to the working dir
     */
    if (stream_name && !(axutil_rindex(stream_name, AXIS2_PATH_SEP_CHAR)))
    {
        path_home = AXIS2_GETENV("AXIS2C_HOME");
        if (path_home)
        {
            AXIS2_SNPRINTF(log_dir, AXUTIL_LOG_FILE_NAME_SIZE, "%s%c%s", 
                path_home, AXIS2_PATH_SEP_CHAR, "logs");
            if (AXIS2_SUCCESS ==
                axutil_file_handler_access(log_dir, AXIS2_F_OK))
            {
                AXIS2_SNPRINTF(log_file_name, AXUTIL_LOG_FILE_NAME_SIZE, 
                    "%s%c%s", log_dir, AXIS2_PATH_SEP_CHAR, tmp_filename);
            }
            else
            {
                fprintf(stderr, "log folder %s does not exist - log file %s "\
                    "is written to . dir\n", log_dir, tmp_filename);
                AXIS2_SNPRINTF(log_file_name, AXUTIL_LOG_FILE_NAME_SIZE, "%s", 
                    tmp_filename);
            }
        }
        else
        {
            fprintf(stderr,
                "AXIS2C_HOME is not set - log is written to . dir\n");
            AXIS2_SNPRINTF(log_file_name, AXUTIL_LOG_FILE_NAME_SIZE, "%s", 
                tmp_filename);
        }
    }
    else
    {
        AXIS2_SNPRINTF(log_file_name, AXUTIL_LOG_FILE_NAME_SIZE, "%s", 
            tmp_filename);
    }
    log_impl->file_name = AXIS2_MALLOC(allocator, AXUTIL_LOG_FILE_NAME_SIZE);
    log_impl->log.size = AXUTIL_LOG_FILE_SIZE;
    sprintf(log_impl->file_name, "%s", log_file_name);

    axutil_thread_mutex_lock(log_impl->mutex);

    log_impl->stream = axutil_file_handler_open(log_file_name, "a+");
    axutil_log_impl_rotate((axutil_log_t *) log_impl);

    axutil_thread_mutex_unlock(log_impl->mutex);

    if (!log_impl->stream)
        log_impl->stream = stderr;

    /* by default, log is enabled */
    log_impl->log.enabled = 1;
    log_impl->log.level = AXIS2_LOG_LEVEL_DEBUG;

    if (ops)
    {
        log_impl->log.ops = ops;
    }
    else
    {
        log_impl->log.ops = &axutil_log_ops_var;
    }

    return &(log_impl->log);
}