[opensuse-programming] Problem on SLES and openSUSE 11.4 and 12.1 short msgget examples that fail to work, but on all UNIX's I have tried.

Here is the some code our examples of 2 c routines for 2 queues and a fortran main line program that calls them. I suspect the problem is an inconsistencey in definitions between the languages. We have over 100,000 lines of code for the programs. I have cut them down to these examples that demostrate the problem. Also below is the results on UNIX and Linux. The negative number is almost always different. Any ideas on how to resolve this would be greatly appreciated. ----------------------------------------------------------------
>>>>>>>>>>> SOURCES>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 2 subroutines in c and a main line in fortran
------------------------------srvq1.c--------------------------- /* create the server input queue (1) */ #include <sys/types.h> #include <sys/ipc.h> #include <sys/msg.h> srvq1_(short *theid) { key_t key; int msgid1, msgflg; key=1; msgflg=IPC_CREAT | 0666; msgid1 = msgget (key, msgflg); if (msgid1 < 0) perror("SRVQ1 - server input queue not created"); *theid=msgid1; } ---------------------------------------------------------------- ------------------------------srvq2.c--------------------------- /* create the server output queue (2) */ #include <sys/types.h> #include <sys/ipc.h> #include <sys/msg.h> srvq2_(short *theid) { key_t key; int msgid2, msgflg; key=2; msgflg=IPC_CREAT | 0666; msgid2 = msgget (key, msgflg); if (msgid2 < 0) perror("SRVQ2 - server output queue not created"); *theid=msgid2; } ---------------------------------------------------------------- ----------------------------------TSERVER.f---------------------------- C TSERVER - TEST SERVER SUBS IMPLICIT INTEGER*4(A-H),INTEGER*4(O-Z) IMPLICIT INTEGER*2(I-N) COMMON /FFT/ XAREA(512) DIMENSION ICON(1024) C CALL GTPID(DPID) C WRITE(*,12)DPID C12 FORMAT(1X,'MY PROCESS ID IS ',I8) CALL SRVQ1(IQ1) WRITE(*,13)IQ1 13 FORMAT(1X,'SERVER INPUT QUEUE ID IS ',I8) IF (IQ1.LT.0) GOTO 9999 CALL SRVQ2(IQ2) WRITE(*,14)IQ2 14 FORMAT(1X,'SERVER OUTPUT QUEUE ID IS ',I8) IF (IQ2.LT.0) GOTO 9999 100 WRITE(*,20) 20 FORMAT(1X,'AWAITING MESSAGES') 9999 END ----------------------------------------------------------------
>>>> RESULTS OF THIS CODE IN SCO 5.07>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>> RESULTS OF THIS CODE IN SUN UNIX>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
$ TSERVST SERVER INPUT QUEUE ID IS 0 SERVER OUTPUT QUEUE ID IS 1 AWAITING MESSAGES
>>>> RESULTS OF THIS CODE IN OPEN SUSE 64 AND SUSE 32>>>>>>>>>>>>>
./TSERVST SERVER INPUT QUEUE ID IS 0 SERVER OUTPUT QUEUE ID IS -32767
---------------------------------------------------------------- Any ideas on how to get this to work? It works with one queue but fails with 2 queues. -- Boyd Gerber <gerberb@zenez.com> 801 849-0213 ZENEZ 1042 East Fort Union #135, Midvale Utah 84047 -- To unsubscribe, e-mail: opensuse-programming+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-programming+owner@opensuse.org

On Saturday 19 November 2011 15:29:19 Boyd Lynn Gerber wrote:
srvq2_(short *theid) { key_t key; int msgid2, msgflg;
key=2; msgflg=IPC_CREAT | 0666;
msgid2 = msgget (key, msgflg);
if (msgid2 < 0) perror("SRVQ2 - server output queue not created");
*theid=msgid2; [...] Any ideas on how to get this to work? It works with one queue but fails with 2 queues.
If you're not seeing the error output, then I can only imagine that you are getting an id that is greater than the size of a short. msgid returns an integer, and converting it to a short could very well cause all sorts of problems. The OS is free to return any kind of identifier there. I'm not sure how to compile that mixture of fortran and C, so I can't check to see if it makes a difference. In general though, it is an error to blindly convert integer to short. Anders -- To unsubscribe, e-mail: opensuse-programming+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-programming+owner@opensuse.org
participants (2)
-
Anders Johansson
-
Boyd Lynn Gerber