[zeromq-dev] ZMQ vs SPI: FD shenanigans
Olaf Mandel
o.mandel at menlosystems.com
Tue Jan 20 15:56:14 CET 2015
Hello Thomas,
thank you for the quick answer.
Am 20.01.2015 15:11, schrieb Thomas Rodgers:
> Do you see the same behavior if you replace C with fopen() ?
-Snipp-
Not quite: if the error occurs, the behaviour is the same as before. But
now the error _always_ happens: closing the file descriptor in the C
version of the test makes no difference. New test below:
/*
* Compile with:
* g++ -Wall -Werror -Wextra -pedantic -x c -o test test.c -lzmq
*/
#include <fcntl.h>
#include <linux/spi/spidev.h>
#include <stdio.h>
#include <string.h>
#include <sys/ioctl.h>
#include <zmq.h>
/*#define ADDR "tcp://127.0.0.1:8000"*/
#define ADDR "inproc://addr"
/*
* The program always shows the problem (independent of the presence
* of D) for the following permutations of the blocks:
* - A B C D
* - A C B D
* - A C D B
* - C A B D
* - C A D B
* - C D A B
*
* With the constraint that A must be before B and C before D, there
* are no further valid permutations.
*
* For the TCP address, the error message is: No such device
* For the inproc address, it is: Resource temporarily unavailable
*/
int main()
{
void* ctx;
void* skt;
FILE* f;
int fd;
struct spi_ioc_transfer pcks;
ctx = zmq_ctx_new(); /* A */
skt = zmq_socket(ctx, ZMQ_PUB); /* B */
zmq_bind(skt, ADDR);
f = fopen("log", "w"); /* C */
(void)sizeof(f);
fclose(f); /* D */
/* The following always last */
fd = open("/dev/spidev32766.0", O_RDWR);
memset(&pcks, 0, sizeof(struct spi_ioc_transfer));
ioctl(fd, SPI_IOC_MESSAGE(1), &pcks);
printf("errno: %s\n", strerror(errno));
return 0;
}
The one advantage of this is: I now at least can see the FILE structure
and the contained _fileno member.
Any further thoughts?
Olaf Mandel
--
Olaf Mandel
phone: +49-89-189166-250
fax: +49-89-189166-111
Menlo Systems GmbH
Am Klopferspitz 19a, D-82152 Martinsried
Amtsgericht München HRB 138145
Geschäftsführung: Dr Michael Mei, Dr Ronald Holzwarth
USt-IdNr. DE217772017, St.-Nr. 14316170324
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20150120/9c96e445/attachment.sig>
More information about the zeromq-dev
mailing list