Catalin Olteanu
2018-07-13 10:39:05 UTC
Hi, Everybody,
I have a service that is creating a shared memory region and then is
sending the file descriptor over the binder as(initially as int32 and after
that, more fancy as ParcelFileDescriptor). I have checked the integrity of
the descriptor using lsof /dev/ashmem | grep `pidof my_pid`.
I see that the descriptor is there and is having the same value as the one
received by the client.
So far so god...now is coming the wrong part...
At client side, the ashmem_getsize_region is returning -1; After that
everything fails..
At service side:
fd = ashmem_create_region("myashmem", 1024);
ashmem_pin_region(fd, 0, 0);
ashmem_set_prot_region(fd,PROT_EXEC|PROT_READ|PROT_WRITE);
// fd = open("/dev/ashmem",O_RDWR);
ALOGD("Demo service is creating the sharedmem(%i) is now ready",fd);
// ioctl(fd,ASHMEM_SET_NAME,"myashmem");
// ioctl(fd,ASHMEM_SET_SIZE,1024);
ALOGD("Region size:%i",ashmem_get_size_region(fd));
size = 1024;
map = (int32_t
*)mmap(NULL,1024,PROT_READ|PROT_WRITE,MAP_SHARED,fd,0);
if( map== MAP_FAILED ) {
ALOGD("Map is failed");
}
On client side:
int32_t fd = demo->get_fd();
ALOGD("FD result: %i", fd);
ALOGD("Region size:%i",ashmem_get_size_region(fd));
I have a service that is creating a shared memory region and then is
sending the file descriptor over the binder as(initially as int32 and after
that, more fancy as ParcelFileDescriptor). I have checked the integrity of
the descriptor using lsof /dev/ashmem | grep `pidof my_pid`.
I see that the descriptor is there and is having the same value as the one
received by the client.
So far so god...now is coming the wrong part...
At client side, the ashmem_getsize_region is returning -1; After that
everything fails..
At service side:
fd = ashmem_create_region("myashmem", 1024);
ashmem_pin_region(fd, 0, 0);
ashmem_set_prot_region(fd,PROT_EXEC|PROT_READ|PROT_WRITE);
// fd = open("/dev/ashmem",O_RDWR);
ALOGD("Demo service is creating the sharedmem(%i) is now ready",fd);
// ioctl(fd,ASHMEM_SET_NAME,"myashmem");
// ioctl(fd,ASHMEM_SET_SIZE,1024);
ALOGD("Region size:%i",ashmem_get_size_region(fd));
size = 1024;
map = (int32_t
*)mmap(NULL,1024,PROT_READ|PROT_WRITE,MAP_SHARED,fd,0);
if( map== MAP_FAILED ) {
ALOGD("Map is failed");
}
On client side:
int32_t fd = demo->get_fd();
ALOGD("FD result: %i", fd);
ALOGD("Region size:%i",ashmem_get_size_region(fd));
--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk+***@googlegroups.com.
To post to this group, send email to android-***@googlegroups.com.
Visit this group at https://groups.google.com/group/android-ndk.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/636856be-d8fa-44fb-b552-5fe81ff13595%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk+***@googlegroups.com.
To post to this group, send email to android-***@googlegroups.com.
Visit this group at https://groups.google.com/group/android-ndk.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/636856be-d8fa-44fb-b552-5fe81ff13595%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.