[
https://issues.apache.org/jira/browse/SOLR-10390?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15947869#comment-15947869
]
Felipe Gasper commented on SOLR-10390:
--------------------------------------
That sounds reasonable. I’d offer to help, but I don’t grok Java. :-/
> lsof has too many kernel dependencies
> -------------------------------------
>
> Key: SOLR-10390
> URL: https://issues.apache.org/jira/browse/SOLR-10390
> Project: Solr
> Issue Type: Bug
> Security Level: Public(Default Security Level. Issues are Public)
> Reporter: Felipe Gasper
>
> lsof seems a very "heavy" solution for just checking whether a socket is
> open. In Linux in particular it's problematic because there are kernel
> options that will break lsof, e.g. CloudLinux's *kernel.user_ptrace* and
> *kernel.user_ptrace_self* options.
> If all that's needed here is a simple connect() to the socket, what about
> shipping something simple like this:
> {code}
> #include <stdio.h>
> #include <stdlib.h>
> #include <string.h>
> #include <sys/types.h>
> #include <sys/socket.h>
> #include <netinet/in.h>
> #include <netdb.h>
> void _fail() {
> exit(EXIT_FAILURE);
> }
> void error(const char *msg) {
> perror(msg);
> _fail();
> }
> int main(int argc, char *argv[]) {
> int sockfd, portno, n;
> struct sockaddr_in serv_addr;
> struct hostent *server;
> char buffer[256];
> if (argc < 3) {
> fprintf(stderr,"usage %s hostname port\n", argv[0]);
> _fail();
> }
> portno = atoi(argv[2]);
> sockfd = socket(AF_INET, SOCK_STREAM, 0);
> if (sockfd < 0) {
> error("ERROR opening socket");
> }
> server = gethostbyname(argv[1]);
> if (server == NULL) {
> fprintf(stderr,"ERROR: no such host\n");
> _fail();
> }
> bzero((char *) &serv_addr, sizeof(serv_addr));
> serv_addr.sin_family = AF_INET;
> bcopy((char *)server->h_addr,
> (char *)&serv_addr.sin_addr.s_addr,
> server->h_length);
> serv_addr.sin_port = htons(portno);
> if (connect(sockfd,(struct sockaddr *) &serv_addr,sizeof(serv_addr)) < 0)
> {
> error("ERROR connecting");
> }
> fprintf(stdout, "OK\n");
> return EXIT_SUCCESS;
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]