mqd_t CreateMessageQueue(std::string queueName) { struct mq_attr attr; /* initialize the queue attributes */ attr.mq_flags = 0; attr.mq_maxmsg = 10; //******perhaps change??****** attr.mq_msgsize = MAX_MESSAGE_SIZE; attr.mq_curmsgs = 0; mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH; mqd_t mq = mq_open(queueName.c_str(), O_CREAT | O_RDWR, mode, &attr); if(errno == EEXIST) { DeleteMessageQueue(queueName); printf("Deleted old message queue"); mq = mq_open(queueName.c_str(), O_CREAT | O_RDWR, (S_IRWXU | S_IRWXG | S_IRWXO), &attr); } else if(mq == -1) { perror("Creating message queue failed"); return (mqd_t)NULL; } printf("Message queue created\n"); return mq; }
HRESULT MqiRollbackCreateMessageQueues( LPWSTR* ppwzData ) { HRESULT hr = S_OK; int iCnt = 0; MQI_MESSAGE_QUEUE_ATTRIBUTES attrs; ::ZeroMemory(&attrs, sizeof(attrs)); // ger count hr = WcaReadIntegerFromCaData(ppwzData, &iCnt); ExitOnFailure(hr, "Failed to read count"); for (int i = 0; i < iCnt; i++) { // read attributes from CustomActionData hr = ReadMessageQueueAttributes(ppwzData, &attrs); ExitOnFailure(hr, "Failed to read attributes"); // create message queue hr = DeleteMessageQueue(&attrs); if (FAILED(hr)) WcaLog(LOGMSG_STANDARD, "Failed to delete message queue, hr: 0x%x, key: %S", hr, attrs.pwzKey); } hr = S_OK; LExit: // clean up FreeMessageQueueAttributes(&attrs); return hr; }
HRESULT MqiDeleteMessageQueues( LPWSTR* ppwzData ) { HRESULT hr = S_OK; int iCnt = 0; MQI_MESSAGE_QUEUE_ATTRIBUTES attrs; ::ZeroMemory(&attrs, sizeof(attrs)); // ger count hr = WcaReadIntegerFromCaData(ppwzData, &iCnt); ExitOnFailure(hr, "Failed to read count"); for (int i = 0; i < iCnt; i++) { // read attributes from CustomActionData hr = ReadMessageQueueAttributes(ppwzData, &attrs); ExitOnFailure(hr, "Failed to read attributes"); // progress message hr = PcaActionDataMessage(1, attrs.pwzPathName); ExitOnFailure1(hr, "Failed to send progress messages, key: %S", attrs.pwzKey); // create message queue hr = DeleteMessageQueue(&attrs); ExitOnFailure1(hr, "Failed to delete message queue, key: %S", attrs.pwzKey); // progress tics hr = WcaProgressMessage(COST_MESSAGE_QUEUE_DELETE, FALSE); ExitOnFailure(hr, "Failed to update progress"); } hr = S_OK; LExit: // clean up FreeMessageQueueAttributes(&attrs); return hr; }