Remove this component; twitter long ago switched to the oauth
authentication, and no one has ever updated this component to match. It can be revived out of history if anyone cares. This commit was SVN r25421.
Этот коммит содержится в:
родитель
891027c10d
Коммит
7f6f7bd0eb
@ -1,47 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
||||
# University Research and Technology
|
||||
# Corporation. All rights reserved.
|
||||
# Copyright (c) 2004-2005 The University of Tennessee and The University
|
||||
# of Tennessee Research Foundation. All rights
|
||||
# reserved.
|
||||
# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
||||
# University of Stuttgart. All rights reserved.
|
||||
# Copyright (c) 2004-2005 The Regents of the University of California.
|
||||
# All rights reserved.
|
||||
# Copyright (c) 2009-2010 Cisco Systems, Inc. All rights reserved.
|
||||
# $COPYRIGHT$
|
||||
#
|
||||
# Additional copyrights may follow
|
||||
#
|
||||
# $HEADER$
|
||||
#
|
||||
|
||||
dist_pkgdata_DATA = \
|
||||
help-orte-notifier-twitter.txt
|
||||
|
||||
sources = \
|
||||
notifier_twitter.h \
|
||||
notifier_twitter_module.c \
|
||||
notifier_twitter_component.c
|
||||
|
||||
# Make the output library in this directory, and name it either
|
||||
# mca_<type>_<name>.la (for DSO builds) or libmca_<type>_<name>.la
|
||||
# (for static builds).
|
||||
|
||||
if MCA_BUILD_orte_notifier_twitter_DSO
|
||||
component_noinst =
|
||||
component_install = mca_notifier_twitter.la
|
||||
else
|
||||
component_noinst = libmca_notifier_twitter.la
|
||||
component_install =
|
||||
endif
|
||||
|
||||
mcacomponentdir = $(pkglibdir)
|
||||
mcacomponent_LTLIBRARIES = $(component_install)
|
||||
mca_notifier_twitter_la_SOURCES = $(sources)
|
||||
mca_notifier_twitter_la_LDFLAGS = -module -avoid-version
|
||||
|
||||
noinst_LTLIBRARIES = $(component_noinst)
|
||||
libmca_notifier_twitter_la_SOURCES =$(sources)
|
||||
libmca_notifier_twitter_la_LDFLAGS = -module -avoid-version
|
@ -1,35 +0,0 @@
|
||||
# -*- shell-script -*-
|
||||
#
|
||||
# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
||||
# University Research and Technology
|
||||
# Corporation. All rights reserved.
|
||||
# Copyright (c) 2004-2005 The University of Tennessee and The University
|
||||
# of Tennessee Research Foundation. All rights
|
||||
# reserved.
|
||||
# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
||||
# University of Stuttgart. All rights reserved.
|
||||
# Copyright (c) 2004-2005 The Regents of the University of California.
|
||||
# All rights reserved.
|
||||
# Copyright (c) 2009-2010 Cisco Systems, Inc. All rights reserved.
|
||||
# $COPYRIGHT$
|
||||
#
|
||||
# Additional copyrights may follow
|
||||
#
|
||||
# $HEADER$
|
||||
#
|
||||
|
||||
# MCA_notifier_twitter_CONFIG([action-if-found], [action-if-not-found])
|
||||
# -----------------------------------------------------------
|
||||
AC_DEFUN([MCA_orte_notifier_twitter_CONFIG], [
|
||||
AC_CONFIG_FILES([orte/mca/notifier/twitter/Makefile])
|
||||
|
||||
# check for sockaddr_in (a good sign we have TCP, which we need to
|
||||
# connect to the Twitter update server)
|
||||
AC_CHECK_TYPES([struct sockaddr_in],
|
||||
[$1],
|
||||
[$2],
|
||||
[AC_INCLUDES_DEFAULT
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
#include <netinet/in.h>
|
||||
#endif])
|
||||
])dnl
|
@ -1,35 +0,0 @@
|
||||
# -*- text -*-
|
||||
#
|
||||
# Copyright (c) 2009 Cisco Systems, Inc. All rights reserved.
|
||||
# $COPYRIGHT$
|
||||
#
|
||||
# Additional copyrights may follow
|
||||
#
|
||||
# $HEADER$
|
||||
#
|
||||
# This is the US/English help file for Open MPI's Twitter notifier support
|
||||
#
|
||||
[only supports http]
|
||||
Sorry, Open MPI's Twitter component currently only supports http URLs
|
||||
for Twitter updates.
|
||||
|
||||
URL supplied: %s
|
||||
#
|
||||
[unable to parse URL]
|
||||
Sorry, Open MPI's Twitter component was unable to parse the Twitter
|
||||
update URL that was provided.
|
||||
|
||||
URL supplied: %s
|
||||
#
|
||||
[unable to resolve server]
|
||||
Sorry, Open MPI's Twitter component was unable to resolve the IP
|
||||
address of the server provided in the Twitter update URL.
|
||||
|
||||
Server: %s
|
||||
#
|
||||
[tweet failed]
|
||||
Oops! Open MPI's Twitter failed to send a tweet.
|
||||
|
||||
Reason: %s (errno: %d)
|
||||
Tweet: %s
|
||||
#
|
@ -1,60 +0,0 @@
|
||||
/* -*- C -*-
|
||||
*
|
||||
* Copyright (c) 2004-2008 The Trustees of Indiana University and Indiana
|
||||
* University Research and Technology
|
||||
* Corporation. All rights reserved.
|
||||
* Copyright (c) 2004-2006 The University of Tennessee and The University
|
||||
* of Tennessee Research Foundation. All rights
|
||||
* reserved.
|
||||
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
||||
* University of Stuttgart. All rights reserved.
|
||||
* Copyright (c) 2004-2005 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2009 Cisco Systems, Inc. All rights reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
*
|
||||
* $HEADER$
|
||||
*
|
||||
*/
|
||||
#ifndef NOTIFIER_TWITTER_H
|
||||
#define NOTIFIER_TWITTER_H
|
||||
|
||||
#include "orte_config.h"
|
||||
|
||||
#include <netdb.h>
|
||||
|
||||
#include "orte/mca/notifier/notifier.h"
|
||||
|
||||
BEGIN_C_DECLS
|
||||
|
||||
typedef struct {
|
||||
orte_notifier_base_component_t super;
|
||||
|
||||
/* Twitter URL, username, and password */
|
||||
char *url;
|
||||
char *server;
|
||||
char *uri;
|
||||
char *username;
|
||||
char *password;
|
||||
|
||||
/* struct hostent from resolved Twitter server name */
|
||||
struct hostent *server_hostent;
|
||||
int port;
|
||||
|
||||
/* Priority of this component */
|
||||
int priority;
|
||||
} orte_notifier_twitter_component_t;
|
||||
|
||||
|
||||
/*
|
||||
* Notifier interfaces
|
||||
*/
|
||||
ORTE_MODULE_DECLSPEC extern orte_notifier_twitter_component_t
|
||||
mca_notifier_twitter_component;
|
||||
extern orte_notifier_base_module_t orte_notifier_twitter_module;
|
||||
|
||||
END_C_DECLS
|
||||
|
||||
#endif
|
@ -1,191 +0,0 @@
|
||||
/* -*- C -*-
|
||||
*
|
||||
* Copyright (c) 2004-2008 The Trustees of Indiana University and Indiana
|
||||
* University Research and Technology
|
||||
* Corporation. All rights reserved.
|
||||
* Copyright (c) 2004-2005 The University of Tennessee and The University
|
||||
* of Tennessee Research Foundation. All rights
|
||||
* reserved.
|
||||
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
||||
* University of Stuttgart. All rights reserved.
|
||||
* Copyright (c) 2004-2005 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2009 Cisco Systems, Inc. All rights reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
*
|
||||
* $HEADER$
|
||||
*/
|
||||
|
||||
/*
|
||||
* Because we can. :-)
|
||||
*/
|
||||
|
||||
#include "orte_config.h"
|
||||
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#include "opal/mca/base/mca_base_param.h"
|
||||
|
||||
#include "orte/constants.h"
|
||||
#include "orte/util/show_help.h"
|
||||
|
||||
#include "notifier_twitter.h"
|
||||
|
||||
static int twitter_component_query(mca_base_module_t **module, int *priority);
|
||||
static int twitter_close(void);
|
||||
static int twitter_register(void);
|
||||
|
||||
/*
|
||||
* Struct of function pointers that need to be initialized
|
||||
*/
|
||||
orte_notifier_twitter_component_t mca_notifier_twitter_component = {
|
||||
{
|
||||
{
|
||||
ORTE_NOTIFIER_BASE_VERSION_1_0_0,
|
||||
|
||||
"twitter",
|
||||
|
||||
ORTE_MAJOR_VERSION,
|
||||
ORTE_MINOR_VERSION,
|
||||
ORTE_RELEASE_VERSION,
|
||||
|
||||
NULL,
|
||||
twitter_close,
|
||||
twitter_component_query,
|
||||
twitter_register,
|
||||
},
|
||||
{
|
||||
/* The component is checkpoint ready */
|
||||
MCA_BASE_METADATA_PARAM_CHECKPOINT
|
||||
}
|
||||
},
|
||||
|
||||
/* Twitter url, username, password */
|
||||
"http://twitter.com/statuses/update.json",
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
|
||||
/* Struct hostent */
|
||||
NULL,
|
||||
80,
|
||||
|
||||
/* Priority */
|
||||
10,
|
||||
};
|
||||
|
||||
static int twitter_register(void)
|
||||
{
|
||||
mca_base_param_reg_string(&mca_notifier_twitter_component.super.base_version,
|
||||
"url",
|
||||
"Twitter update URL",
|
||||
false, false,
|
||||
mca_notifier_twitter_component.url,
|
||||
&mca_notifier_twitter_component.url);
|
||||
mca_base_param_reg_string(&mca_notifier_twitter_component.super.base_version,
|
||||
"username",
|
||||
"Twitter username",
|
||||
false, false, NULL,
|
||||
&mca_notifier_twitter_component.username);
|
||||
mca_base_param_reg_string(&mca_notifier_twitter_component.super.base_version,
|
||||
"password",
|
||||
"Twitter password",
|
||||
false, false, NULL,
|
||||
&mca_notifier_twitter_component.password);
|
||||
|
||||
mca_base_param_reg_int(&mca_notifier_twitter_component.super.base_version,
|
||||
"priority",
|
||||
"Priority of this component",
|
||||
false, false,
|
||||
mca_notifier_twitter_component.priority,
|
||||
&mca_notifier_twitter_component.priority);
|
||||
return ORTE_SUCCESS;
|
||||
}
|
||||
|
||||
static int twitter_close(void)
|
||||
{
|
||||
if (NULL != mca_notifier_twitter_component.url) {
|
||||
free(mca_notifier_twitter_component.url);
|
||||
}
|
||||
if (NULL != mca_notifier_twitter_component.username) {
|
||||
free(mca_notifier_twitter_component.username);
|
||||
}
|
||||
if (NULL != mca_notifier_twitter_component.password) {
|
||||
free(mca_notifier_twitter_component.password);
|
||||
}
|
||||
|
||||
return ORTE_SUCCESS;
|
||||
}
|
||||
|
||||
static int twitter_component_query(mca_base_module_t **module,
|
||||
int *priority)
|
||||
{
|
||||
char *str;
|
||||
|
||||
/* If we have no username or password, there's no love */
|
||||
if (NULL == mca_notifier_twitter_component.username ||
|
||||
NULL == mca_notifier_twitter_component.password) {
|
||||
return ORTE_ERR_NOT_FOUND;
|
||||
}
|
||||
|
||||
/* Parse out the URL into a server and URI, ensuring that we can
|
||||
handle it */
|
||||
if (0 != strncmp(mca_notifier_twitter_component.url, "http://", 7)) {
|
||||
orte_show_help("help-orte-notifier-twitter.txt", "only supports http",
|
||||
true, mca_notifier_twitter_component.url);
|
||||
return ORTE_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
/* There's a / between the server name and URI */
|
||||
str = strchr(mca_notifier_twitter_component.url + 7, '/');
|
||||
if (NULL == str) {
|
||||
orte_show_help("help-orte-notifier-twitter.txt",
|
||||
"unable to parse URL",
|
||||
true, mca_notifier_twitter_component.url);
|
||||
return ORTE_ERR_NOT_FOUND;
|
||||
}
|
||||
*str = '\0';
|
||||
mca_notifier_twitter_component.server =
|
||||
mca_notifier_twitter_component.url + 7;
|
||||
mca_notifier_twitter_component.uri = str + 1;
|
||||
/* Sanity checks */
|
||||
if (NULL == mca_notifier_twitter_component.server ||
|
||||
NULL == mca_notifier_twitter_component.uri ||
|
||||
'\0' == mca_notifier_twitter_component.server[0] ||
|
||||
'\0' == mca_notifier_twitter_component.uri[0]) {
|
||||
orte_show_help("help-orte-notifier-twitter.txt",
|
||||
"unable to parse URL",
|
||||
true, mca_notifier_twitter_component.url);
|
||||
return ORTE_ERR_NOT_FOUND;
|
||||
}
|
||||
|
||||
/* See if there's a port number in the server name */
|
||||
str = strchr(mca_notifier_twitter_component.server, ':');
|
||||
if (NULL != str) {
|
||||
*str = '\0';
|
||||
mca_notifier_twitter_component.port = atoi(str + 1);
|
||||
} else {
|
||||
mca_notifier_twitter_component.port = 80;
|
||||
}
|
||||
|
||||
/* Since we have to open a socket later, try to resolve the IP
|
||||
address of the server now. Save the result, or abort if we
|
||||
can't resolve it. */
|
||||
mca_notifier_twitter_component.server_hostent =
|
||||
gethostbyname(mca_notifier_twitter_component.server);
|
||||
if (NULL == mca_notifier_twitter_component.server_hostent) {
|
||||
orte_show_help("help-orte-notifier-twitter.txt",
|
||||
"unable to resolve server",
|
||||
true, mca_notifier_twitter_component.server);
|
||||
return ORTE_ERR_NOT_FOUND;
|
||||
}
|
||||
|
||||
*priority = 10;
|
||||
*module = (mca_base_module_t *)&orte_notifier_twitter_module;
|
||||
return ORTE_SUCCESS;
|
||||
}
|
@ -1,309 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
||||
* University Research and Technology
|
||||
* Corporation. All rights reserved.
|
||||
* Copyright (c) 2004-2005 The University of Tennessee and The University
|
||||
* of Tennessee Research Foundation. All rights
|
||||
* reserved.
|
||||
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
||||
* University of Stuttgart. All rights reserved.
|
||||
* Copyright (c) 2004-2005 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2007-2009 Sun Microsystems, Inc. All rights reserved.
|
||||
* Copyright (c) 2009-2011 Cisco Systems, Inc. All rights reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
*
|
||||
* $HEADER$
|
||||
*/
|
||||
|
||||
/*
|
||||
* Because we can. :-)
|
||||
*/
|
||||
|
||||
#include "orte_config.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#ifdef HAVE_STDARG_H
|
||||
#include <stdarg.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
#if HAVE_NETINET_IN_H
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
|
||||
#include "opal/util/show_help.h"
|
||||
|
||||
#include "orte/version.h"
|
||||
#include "orte/constants.h"
|
||||
#include "orte/mca/ess/ess.h"
|
||||
#include "orte/util/error_strings.h"
|
||||
#include "orte/util/name_fns.h"
|
||||
#include "orte/util/show_help.h"
|
||||
#include "orte/runtime/orte_globals.h"
|
||||
#include "orte/mca/notifier/base/base.h"
|
||||
|
||||
#include "notifier_twitter.h"
|
||||
|
||||
|
||||
/* Static API's */
|
||||
static void mylog(orte_notifier_base_severity_t severity, int errcode,
|
||||
const char *msg, va_list ap);
|
||||
static void myhelplog(orte_notifier_base_severity_t severity, int errcode,
|
||||
const char *filename,
|
||||
const char *topic, va_list ap);
|
||||
static void mypeerlog(orte_notifier_base_severity_t severity, int errcode,
|
||||
orte_process_name_t *peer_proc,
|
||||
const char *msg, va_list ap);
|
||||
|
||||
/* Module */
|
||||
orte_notifier_base_module_t orte_notifier_twitter_module = {
|
||||
NULL,
|
||||
NULL,
|
||||
mylog,
|
||||
myhelplog,
|
||||
mypeerlog,
|
||||
NULL
|
||||
};
|
||||
|
||||
static char base64_convert(uint8_t i)
|
||||
{
|
||||
if (i < 26) {
|
||||
return 'A' + i;
|
||||
} else if (i < 52) {
|
||||
return 'a' + i - 26;
|
||||
} else if (i < 62) {
|
||||
return '0' + i - 52;
|
||||
} else if (62 == i) {
|
||||
return '+';
|
||||
} else {
|
||||
return '/';
|
||||
}
|
||||
}
|
||||
|
||||
static void base64_encode(const char *input, char *output, int olen)
|
||||
{
|
||||
int ilen, i, j;
|
||||
uint8_t c;
|
||||
const char pad = '=';
|
||||
|
||||
/* Simplistic loop for base64 encoding */
|
||||
memset(output, 0, olen);
|
||||
ilen = (int) strlen(input);
|
||||
for (j = i = 0; j + 4 < olen && i < ilen; i += 3) {
|
||||
/* First output character is always emitted with no
|
||||
complications */
|
||||
c = input[i] >> 2;
|
||||
output[j++] = base64_convert(c);
|
||||
|
||||
/* If we do not have another input character, then the next
|
||||
output character is just the last 2 bits of the current
|
||||
input character, shifted up 4 bits, and then output 2
|
||||
='s */
|
||||
if (i + 1 == ilen) {
|
||||
c = (input[i] & 3) << 4;
|
||||
output[j++] = base64_convert(c);
|
||||
output[j++] = pad;
|
||||
output[j++] = pad;
|
||||
} else {
|
||||
c = ((input[i] & 3) << 4) + (input[i + 1] >> 4);
|
||||
output[j++] = base64_convert(c);
|
||||
|
||||
/* If we do not have another input character, then the
|
||||
next output character is just the last 4 bits of the
|
||||
current input character. Then output a single =. */
|
||||
if (i + 2 == ilen) {
|
||||
c = (input[i + 1] & 15) << 2;
|
||||
output[j++] = base64_convert(c);
|
||||
output[j++] = pad;
|
||||
} else {
|
||||
c = ((input[i + 1] & 15) << 2) + (input[i + 2] >> 6);
|
||||
output[j++] = base64_convert(c);
|
||||
|
||||
c = (input[i + 2] & 63);
|
||||
output[j++] = base64_convert(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (j >= olen) {
|
||||
output[sizeof(output) - 1] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
static char *auth_basic(void)
|
||||
{
|
||||
char *str;
|
||||
static char output[256];
|
||||
|
||||
asprintf(&str, "%s:%s", mca_notifier_twitter_component.username,
|
||||
mca_notifier_twitter_component.password);
|
||||
memset(output, 0, sizeof(output));
|
||||
base64_encode(str, output, sizeof(output));
|
||||
free(str);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
static char *version_string(void)
|
||||
{
|
||||
int i;
|
||||
static char temp[BUFSIZ];
|
||||
mca_base_component_t *c =
|
||||
&(mca_notifier_twitter_component.super.base_version);
|
||||
|
||||
memset(temp, 0, sizeof(temp));
|
||||
snprintf(temp, BUFSIZ - 1, "%d.%d",
|
||||
c->mca_component_major_version,
|
||||
c->mca_component_minor_version);
|
||||
i = strlen(temp);
|
||||
|
||||
if (c->mca_component_release_version > 0) {
|
||||
snprintf(temp + i, sizeof(temp) - i, ".%d",
|
||||
c->mca_component_release_version);
|
||||
i = strlen(temp);
|
||||
}
|
||||
|
||||
if (strlen(ORTE_GREEK_VERSION) > 0) {
|
||||
strncat(temp + i, ORTE_GREEK_VERSION, sizeof(temp) - i);
|
||||
i = strlen(temp);
|
||||
}
|
||||
|
||||
if (ORTE_WANT_REPO_REV && strlen(ORTE_REPO_REV) > 0) {
|
||||
strncat(temp + i, ORTE_REPO_REV, sizeof(temp) - i);
|
||||
}
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
static void tweet(char *msg)
|
||||
{
|
||||
int fd, ret, sent, len;
|
||||
char *str, buf[80];
|
||||
struct sockaddr_in peer;
|
||||
|
||||
if (NULL == msg) {
|
||||
return;
|
||||
}
|
||||
|
||||
asprintf(&str, "POST /%s HTTP/1.1\nAuthorization: Basic %s\nUser-Agent: Open MPI %s Twitter notifier\nHost: %s\nAccept: */*\nContent-Length: %d\nContent-Type: application/x-www-form-urlencoded\n\nstatus=%s",
|
||||
mca_notifier_twitter_component.uri,
|
||||
auth_basic(),
|
||||
version_string(),
|
||||
mca_notifier_twitter_component.server,
|
||||
(int) (strlen(msg) + strlen("status=")),
|
||||
msg);
|
||||
|
||||
/* Get a socket */
|
||||
fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
if (fd < 0) {
|
||||
orte_show_help("help-orte-notifier-twitter.txt",
|
||||
"tweet failed",
|
||||
true, "socket() system call failed", errno,
|
||||
msg);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Connect to the server */
|
||||
memset(&peer, 0, sizeof(peer));
|
||||
peer.sin_family = AF_INET;
|
||||
memcpy((char *) &peer.sin_addr,
|
||||
mca_notifier_twitter_component.server_hostent->h_addr,
|
||||
sizeof(peer.sin_addr));
|
||||
peer.sin_port = htons(mca_notifier_twitter_component.port);
|
||||
ret = connect(fd, (const struct sockaddr *) &peer, sizeof(peer));
|
||||
if (ret < 0) {
|
||||
orte_show_help("help-orte-notifier-twitter.txt",
|
||||
"tweet failed",
|
||||
true, "connect() system call failed", errno,
|
||||
msg);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Send HTTP update */
|
||||
for (sent = 0, len = strlen(str); sent < len; ) {
|
||||
ret = write(fd, str, strlen(str));
|
||||
if (ret > 0) {
|
||||
str += ret;
|
||||
sent += ret;
|
||||
} else if (0 == ret) {
|
||||
/* ??? */
|
||||
break;
|
||||
} else {
|
||||
/* If we were interrupted by a signal, no problem */
|
||||
if (EINTR == errno) {
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Shutdown nicely; send a FIN */
|
||||
shutdown(fd, SHUT_WR);
|
||||
while (1) {
|
||||
ret = read(fd, buf, sizeof(buf));
|
||||
if (0 == ret) {
|
||||
/* Server ACK'ed the FIN */
|
||||
break;
|
||||
} else if (ret > 0) {
|
||||
/* Print what the server sent us */
|
||||
buf[ret] = '\0';
|
||||
} else {
|
||||
/* If we were interrupted by a signal, no problem */
|
||||
if (EINTR == errno) {
|
||||
continue;
|
||||
}
|
||||
/* Otherwise, just bail */
|
||||
break;
|
||||
}
|
||||
}
|
||||
close(fd);
|
||||
}
|
||||
|
||||
static void mylog(orte_notifier_base_severity_t severity, int errcode,
|
||||
const char *msg, va_list ap)
|
||||
{
|
||||
char *output;
|
||||
|
||||
/* If there was a message, output it */
|
||||
vasprintf(&output, msg, ap);
|
||||
|
||||
if (NULL != output) {
|
||||
tweet(output);
|
||||
free(output);
|
||||
}
|
||||
}
|
||||
|
||||
static void myhelplog(orte_notifier_base_severity_t severity, int errcode,
|
||||
const char *filename,
|
||||
const char *topic, va_list ap)
|
||||
{
|
||||
char *output = opal_show_help_vstring(filename, topic, false, ap);
|
||||
|
||||
if (NULL != output) {
|
||||
tweet(output);
|
||||
free(output);
|
||||
}
|
||||
}
|
||||
|
||||
static void mypeerlog(orte_notifier_base_severity_t severity, int errcode,
|
||||
orte_process_name_t *peer_proc, const char *msg,
|
||||
va_list ap)
|
||||
{
|
||||
char *buf = orte_notifier_base_peer_log(errcode, peer_proc, msg, ap);
|
||||
|
||||
if (NULL != buf) {
|
||||
tweet(buf);
|
||||
free(buf);
|
||||
}
|
||||
|
||||
}
|
Загрузка…
Ссылка в новой задаче
Block a user