메시지 큐 타입 관련.. msgsnd

 

IPC 를 위해 MessageQueue 를 사용해야 했다.

그런데 문제는 msgsnd 시스템 함수를 통해 데이터를 보낼려고 하는데 자꾸 에러가 나는것..

[22:17:29.537][/home/jonathan/workspace/19.Projects/CUTE/source/oxdsagent/queuectl.cpp,232]<ERR>Queue Create Failed. Queue Already Created. Id[4653059]
[22:17:29.537][/home/jonathan/workspace/19.Projects/CUTE/source/oxdsagent/queuectl.cpp,217]<ERR>Queue Create Failed. Invalid Queue Key[-1]
[22:17:29.537][/home/jonathan/workspace/19.Projects/CUTE/source/oxdsagent/queuectl.cpp,217]<ERR>Queue Create Failed. Invalid Queue Key[1215752192]
[22:17:29.537][/home/jonathan/workspace/19.Projects/CUTE/source/oxdsagent/queuectl.cpp,224]<ERR>Queue Create Failed. Invalid Queue Size!! Size[1215752192]
[22:17:29.537][/home/jonathan/workspace/19.Projects/CUTE/source/oxdsagent/queuectl.cpp,283][3]<INF>Queue Create Success!! Input Key[494949], Size[10000] => Created Key[494949], Id[4685827], Size[10000]
[22:17:29.537][/home/jonathan/workspace/19.Projects/CUTE/source/oxdsagent/queuectl.cpp,283][3]<INF>Queue Create Success!! Input Key[494949], Size[10000] => Created Key[494949], Id[4718595], Size[10000]
[22:17:29.537][/home/jonathan/workspace/19.Projects/CUTE/source/oxdsagent/queuectl.cpp,84][3]<INF>Queue Write. Id[4718595],Type[0],Buf[THIS IS TEST],Size[5]
[22:17:29.538][/home/jonathan/workspace/19.Projects/CUTE/source/nxlib/common/queue.c,195][1]<WriteQueue>msgsnd error:-1, 22(Invalid argument)
[22:17:29.538][/home/jonathan/workspace/19.Projects/CUTE/source/nxlib/common/queue.c,196][1]<WriteQueue>Info Id[4718595], Type[0], Data[THIS ], Len[5], Ret[-1]
[22:17:29.538][/home/jonathan/workspace/19.Projects/CUTE/source/oxdsagent/queuectl.cpp,88]<ERR>Queue Write Failed!

로그 내용이다.. 문제가 생기는 부분은 마지막 부분의 <WriteQueue>msgsnd error:-1, 22(Invalid argument) 부분.

전혀 문제가 발생할 부분이 없는데 문제가 발생해서 한참을 헤매다가 겨우답을 찾았다.

 

msgsnd 의 맨페이지에서 답을 찾을 수 있었다.

DESCRIPTION
The  msgsnd()  and  msgrcv() system calls are used, respectively, to send messages to, and receive messages from, a message queue.  The calling process must have write permission on the
message queue in order to send a message, and read permission to receive a message.

The msgp argument is a pointer to caller-defined structure of the following general form:

struct msgbuf {
long mtype;       /* message type, must be > 0 */
char mtext[1];    /* message data */
};

The mtext field is an array (or other structure) whose size is specified by msgsz, a nonnegative integer value.  Messages of zero length (i.e., no mtext field) are permitted.  The mtype
field must have a strictly positive integer value.  This value can be used by the receiving process for message selection (see the description of msgrcv() below).

문제는 메시지 큐 타입을 ‘0’으로 하고 msgsnd를 호출 했던 것…

맨페이지에 명확하게 적혀 있었다.”/* message type, must be > 0 */” …. 아..;;

 

큐 타입을 1로 하고 호출하자 정상 작동 되었다.

CIDS_SIP 프로젝트..

지능형 발신장치 CIDS(Communication Intelligence Dialing System)의 SIP 버전을 위한 개발 프로젝트이다.
기존에 개발되었지만 사용하지 않았던 CIDS_SIP 버전을 현재 사용중인 CIOD 와 맞물리는 작업.

이번 프로젝트에 TDD(Test Driven Development) 와 CMake 를 이용해서 개발을 진행하려 한다.

 

 

 

특정 폴더 제외 후 압축하기

 

리눅스/유닉스 환경에서 디렉토리 압축을 할 때, 특정 디렉토리를 제외하고 압축을 해야하는 경우가 있다.

흔히 로그 디렉토리같은 경우는 용량이 커서 압축시 제외를 해야하는데 이럴때는 다음과 같이 사용하면 된다.

 

eclipse 디렉토리에 다음과 같이 구조되어 있다고 보자.

jonathan@jonathan-laptop:~$ ls -l eclipse/
total 684
-rw-r–r–  1 jonathan jonathan  18909 2011-02-10 12:31 about.html
drwxr-sr-x  2 jonathan jonathan   4096 2011-09-28 14:03 about_files
-rw-rw-r–  1 jonathan jonathan 186294 2012-03-29 17:57 artifacts.xml
drwxrwsr-x 10 jonathan jonathan   4096 2012-04-16 13:24 configuration
drwxrwsr-x  2 jonathan jonathan   4096 2010-09-17 16:37 dropins
-rwxr-xr-x  1 jonathan jonathan  63001 2010-10-19 13:44 eclipse
-rw-rw-r–  1 jonathan jonathan    426 2012-03-29 17:57 eclipse.ini
-rw-r–r–  1 jonathan jonathan  16536 2005-02-25 18:53 epl-v10.html
drwxrwsr-x 80 jonathan jonathan  16384 2012-03-29 17:57 features
-rw-r–r–  1 jonathan jonathan   9022 2006-12-11 11:04 icon.xpm
-rwxr-xr-x  1 jonathan jonathan 266168 2006-12-11 11:04 libcairo-swt.so
-rw-r–r–  1 jonathan jonathan   9051 2010-04-27 15:23 notice.html
drwxrwsr-x  5 jonathan jonathan   4096 2010-09-17 16:35 p2
drwxrwsr-x 29 jonathan jonathan  69632 2012-03-29 17:57 plugins
drwxr-sr-x  2 jonathan jonathan   4096 2011-09-28 14:03 readme

이중, p2, plugins, readme 디렉토리를 제외하고 압축을 시도해 보자.
다음과 같이 입력한다.

tar cvfz test.tar.gz eclipse –exclude=eclipse/p2 –exclude=eclipse/plugins –exclude=eclipse/readme