Skip to content

Commit

Permalink
Changes to stop() method after iRODS change removing the stop() metho…
Browse files Browse the repository at this point in the history
…d from being called within destructor which allowed the use of global variables used elsewhere. Also removed the dependency in CMakeLists.txt to not require qpid-client
  • Loading branch information
JustinKyleJames committed Aug 2, 2017
1 parent 94077f6 commit bc846cd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 20 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Expand Up @@ -170,7 +170,7 @@ set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${CMAKE_SOURCE_DIR}/packaging/postinst")
set(CPACK_ARCHIVE_COMPONENT_INSTALL OFF)

set(CPACK_DEBIAN_PACKAGE_NAME "irods-rule-engine-plugin-audit-amqp")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "${IRODS_PACKAGE_DEPENDENCIES_STRING}, irods-runtime (= ${IRODS_VERSION}), libc6, qpid-client, irods-externals-qpid-with-proton0.34-0")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "${IRODS_PACKAGE_DEPENDENCIES_STRING}, irods-runtime (= ${IRODS_VERSION}), libc6, irods-externals-qpid-with-proton0.34-0")

set(CPACK_RPM_PACKAGE_NAME "irods-rule-engine-plugin-audit-amqp")
if (IRODS_LINUX_DISTRIBUTION_NAME STREQUAL "centos" OR IRODS_LINUX_DISTRIBUTION_NAME STREQUAL "centos linux")
Expand Down
28 changes: 9 additions & 19 deletions libirods_rule_engine_plugin-audit_amqp.cpp
Expand Up @@ -186,8 +186,10 @@ irods::error start(irods::default_re_ctx& _u,const std::string& _instance_name)
return SUCCESS();
}

irods::error stop(irods::default_re_ctx& _u,const std::string&) {

irods::error stop(irods::default_re_ctx& _u,const std::string& _instance_name) {

std::lock_guard<std::mutex> lock(audit_plugin_mutex);

json_t* obj = json_object();
if( !obj ) {
return ERROR(SYS_MALLOC_ERR, "json_object() failed");
Expand Down Expand Up @@ -223,15 +225,15 @@ irods::error stop(irods::default_re_ctx& _u,const std::string&) {
pn_data_t * body;

message = pn_message();

std::string address = audit_amqp_location + "/" + audit_amqp_topic;

pn_message_set_address(message, address.c_str());

body = pn_message_body(message);

pn_data_put_string(body, pn_bytes(msg_str.length(), msg_str.c_str()));
pn_messenger_put(messenger, message);
pn_messenger_send(messenger, -1);

pn_message_free(message);

free(tmp_buf);
Expand All @@ -241,14 +243,8 @@ irods::error stop(irods::default_re_ctx& _u,const std::string&) {
pn_messenger_free(messenger);

if (test_mode) {
if (!log_file_ofstream.is_open()) {
std::ofstream of;
of.open(log_file, std::ios::app);
of << msg_str << std::endl;
} else {
log_file_ofstream << msg_str << std::endl;
log_file_ofstream.close();
}
log_file_ofstream << msg_str << std::endl;
log_file_ofstream.close();
}

return SUCCESS();
Expand Down Expand Up @@ -378,20 +374,14 @@ irods::error exec_rule(
body = pn_message_body(message);
pn_data_put_string(body, pn_bytes(msg_str.length(), msg_str.c_str()));
pn_messenger_put(messenger, message);
//rodsLog(LOG_NOTICE, "pn_messenger_put errno = %i", pn_messenger_errno(messenger));
pn_messenger_send(messenger, -1);
//rodsLog(LOG_NOTICE, "pn_messenger_send errno = %i", pn_messenger_errno(messenger));

pn_message_free(message);

free(tmp_buf);
json_decref(obj);


if (test_mode) {
//std::ofstream log_file_ofstream;
//std::string log_file = str(boost::format("%s/%06i.txt") % log_path_prefix % pid);
//log_file_ofstream.open(log_file, std::ios::app);
log_file_ofstream << msg_str << std::endl;
}

Expand Down

0 comments on commit bc846cd

Please sign in to comment.