v0.7.2: ipcd indicates if it successfully contacted the service.
This commit is contained in:
parent
c69ce64273
commit
825e0c1b2c
18
Makefile
18
Makefile
@ -1,5 +1,5 @@
|
||||
PACKAGE = 'libipc'
|
||||
VERSION = '0.7.1'
|
||||
VERSION = '0.7.2'
|
||||
|
||||
PREFIX := /usr/local
|
||||
BINDIR := $(PREFIX)/bin
|
||||
@ -50,23 +50,23 @@ libipc.so: src/communication.o src/context.o src/error.o src/fs.o src/message.o
|
||||
$(Q)$(CC) -o libipc.so -shared $(LDFLAGS) src/communication.o src/context.o src/error.o src/fs.o src/message.o src/network.o src/print.o src/service_path.o src/usocket.o src/utils.o
|
||||
|
||||
libipc.so.install: libipc.so
|
||||
@echo '[01;31m IN > [01;37m$(LIBDIR)/libipc.so.0.7.1[00m'
|
||||
@echo '[01;31m IN > [01;37m$(LIBDIR)/libipc.so.0.7.2[00m'
|
||||
$(Q)mkdir -p '$(DESTDIR)$(LIBDIR)'
|
||||
$(Q)install -m0755 libipc.so $(DESTDIR)$(LIBDIR)/libipc.so.0.7.1
|
||||
$(Q)install -m0755 libipc.so $(DESTDIR)$(LIBDIR)/libipc.so.0.7.2
|
||||
@echo '[01;35m LN > [01;37m$(LIBDIR)/libipc.so.0.7[00m'
|
||||
$(Q)ln -sf '$(LIBDIR)/libipc.so.0.7.1' '$(DESTDIR)/$(LIBDIR)/libipc.so.0.7'
|
||||
$(Q)ln -sf '$(LIBDIR)/libipc.so.0.7.2' '$(DESTDIR)/$(LIBDIR)/libipc.so.0.7'
|
||||
@echo '[01;35m LN > [01;37m$(LIBDIR)/libipc.so.0[00m'
|
||||
$(Q)ln -sf '$(LIBDIR)/libipc.so.0.7.1' '$(DESTDIR)/$(LIBDIR)/libipc.so.0'
|
||||
$(Q)ln -sf '$(LIBDIR)/libipc.so.0.7.2' '$(DESTDIR)/$(LIBDIR)/libipc.so.0'
|
||||
@echo '[01;35m LN > [01;37m$(LIBDIR)/libipc.so[00m'
|
||||
$(Q)ln -sf '$(LIBDIR)/libipc.so.0.7.1' '$(DESTDIR)/$(LIBDIR)/libipc.so'
|
||||
$(Q)ln -sf '$(LIBDIR)/libipc.so.0.7.2' '$(DESTDIR)/$(LIBDIR)/libipc.so'
|
||||
|
||||
libipc.so.clean:
|
||||
@echo '[01;37m RM > [01;37mlibipc.so[00m'
|
||||
$(Q)rm -f libipc.so
|
||||
|
||||
libipc.so.uninstall:
|
||||
@echo '[01;37m RM > [01;37m$(LIBDIR)/libipc.so.0.7.1[00m'
|
||||
$(Q)rm -f '$(DESTDIR)$(LIBDIR)/libipc.so.0.7.1'
|
||||
@echo '[01;37m RM > [01;37m$(LIBDIR)/libipc.so.0.7.2[00m'
|
||||
$(Q)rm -f '$(DESTDIR)$(LIBDIR)/libipc.so.0.7.2'
|
||||
@echo '[01;37m RM > [01;37m$(LIBDIR)/libipc.so.0.7[00m'
|
||||
$(Q)rm -f '$(DESTDIR)$(LIBDIR)/libipc.so.0.7'
|
||||
@echo '[01;37m RM > [01;37m$(LIBDIR)/libipc.so.0[00m'
|
||||
@ -327,7 +327,7 @@ $(PACKAGE)-$(VERSION).tar.bz2: distdir
|
||||
$(PACKAGE)-$(VERSION)/src/utils.h
|
||||
|
||||
help:
|
||||
@echo '[01;37m :: libipc-0.7.1[00m'
|
||||
@echo '[01;37m :: libipc-0.7.2[00m'
|
||||
@echo ''
|
||||
@echo '[01;37mGeneric targets:[00m'
|
||||
@echo '[00m - [01;32mhelp [37m Prints this help message.[00m'
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
package=libipc # Package name.
|
||||
version=0.7.1 # Package version.
|
||||
version=0.7.2 # Package version.
|
||||
|
||||
# Our targets are the library and its documentation.
|
||||
targets=(libipc man/libipc.7)
|
||||
|
@ -58,9 +58,11 @@ struct ipc_error ipc_contact_ipcd (int *pfd, const char *sname)
|
||||
T_R ((pfd == NULL), IPC_ERROR_CONTACT_IPCD__NO_FD_PARAM);
|
||||
T_R ((sname == NULL), IPC_ERROR_CONTACT_IPCD__NO_SERVICE_NAME_PARAM);
|
||||
|
||||
// In case there is a problem with ipcd.
|
||||
*pfd = 0;
|
||||
|
||||
char *ipcd_var = getenv ("IPC_NETWORK");
|
||||
if (ipcd_var == NULL) {
|
||||
*pfd = 0;
|
||||
IPC_RETURN_NO_ERROR;
|
||||
}
|
||||
// TODO: is there another, more interesting way to do this?
|
||||
@ -73,7 +75,6 @@ struct ipc_error ipc_contact_ipcd (int *pfd, const char *sname)
|
||||
memcpy (columnthensname + 1, sname, strlen (sname));
|
||||
|
||||
if (strncmp (ipcd_var, sname, strlen (sname)) != 0 && strstr (ipcd_var, columnthensname) == NULL) {
|
||||
*pfd = 0;
|
||||
IPC_RETURN_NO_ERROR;
|
||||
}
|
||||
|
||||
@ -95,7 +96,24 @@ struct ipc_error ipc_contact_ipcd (int *pfd, const char *sname)
|
||||
msg.length = strlen (content);
|
||||
msg.payload = content;
|
||||
|
||||
TEST_IPC_RR (ipc_write_fd (ipcd_fd, &msg), "cannot send a message to networkd");
|
||||
TEST_IPC_RR (ipc_write_fd (ipcd_fd, &msg), "cannot send a message to ipcd");
|
||||
|
||||
memset (&msg, 0, sizeof(struct ipc_message));
|
||||
|
||||
// ipcd successfully contacted the service or failed.
|
||||
// ipcd will tell either OK or NOT OK.
|
||||
TEST_IPC_RR (ipc_read_fd (ipcd_fd, &msg), "cannot read the ipcd response");
|
||||
|
||||
// In case ipcd failed.
|
||||
if (msg.length != 2) {
|
||||
printf ("ipcd failed to contact service: (%d bytes) %s\n"
|
||||
, msg.length
|
||||
, msg.payload);
|
||||
SECURE_DECLARATION(struct ipc_error, ret);
|
||||
ret.error_code = IPC_ERROR_CLOSED_RECIPIENT;
|
||||
usock_close (ipcd_fd);
|
||||
return ret;
|
||||
}
|
||||
|
||||
struct ipc_error ret = ipc_receive_fd (ipcd_fd, pfd);
|
||||
if (ret.error_code == IPC_ERROR_NONE) {
|
||||
@ -116,7 +134,7 @@ struct ipc_error ipc_connection_ (struct ipc_ctx *ctx, const char *sname, enum i
|
||||
SECURE_DECLARATION(struct pollfd, pollfd);
|
||||
pollfd.events = POLLIN;
|
||||
|
||||
TEST_IPC_P (ipc_contact_ipcd (&pollfd.fd, sname), "error during networkd connection");
|
||||
TEST_IPC_P (ipc_contact_ipcd (&pollfd.fd, sname), "error during ipcd connection");
|
||||
|
||||
// if ipcd did not initiate the connection
|
||||
if (pollfd.fd <= 0) {
|
||||
|
Reference in New Issue
Block a user