~ubuntu-branches/ubuntu/trusty/uwsgi/trusty

« back to all changes in this revision

Viewing changes to rpc.c

  • Committer: Package Import Robot
  • Author(s): Janos Guljas
  • Date: 2012-02-13 03:43:28 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20120213034328-d02hz8m5pon6kaxf
Tags: 1.0.3+dfsg-1
* New upstream version.
* Adjust rack plugin LD_RUN_PATH patch.
* Adjust patch for uWSGI Control Center jQuery links in templates.
* Remove '-fno-strict-aliasing' CFLAG patch as it is implemented upstream.
* Remove fix indentation of uwsgidecorators_py patch as implemented upstream.
* Adjust init scripts to use top-bottom options order, as --inherit option
  is not working as in earlier versions. 
* Update debian/copyright file.
* Add LSB Description field to debian/uwsgi.init.d.
* Set Architecture to "all" for binary package uwsgi-extra because
  it contains no architecture dependent files.
* Change uwsgi description. (Closes: #640698)
* New binary packages:
  - uwsgi-plugin-carbon
  - uwsgi-plugin-graylog2
  - uwsgi-plugin-logsocket
  - uwsgi-plugin-probeconnect
  - uwsgi-plugin-probepg
  - uwsgi-plugin-rrdtool
  - uwsgi-plugin-rsyslog
  - uwsgi-plugin-signal
  - uwsgi-plugin-symcall
  - uwsgi-plugin-syslog
* python-uwsgidecorators:
  - fix binary-install rule to call dh_python2
  - remove debian/source.lintian-overrides
* uwsgi-plugin-jvm-openjdk-6:
  - fix FTBFS on armel and powerpc (Closes: #656280)
* uwsgi-plugin-python:
  - document issue "ImportError: No module named site" when using
    virtualenv with Python 2.6 in README.Debian (Closes: #654333)
* Adjust debian/watch uversionmangle option.
* Repack upstram source to remove minimized jQuery and jQuery UI JavaScript
  libraries:
  - add get-orig-source rule to debian/rules
  - append +dfsg to upstream version
  - update debian/watch with dversionmangle option

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
        return ret;
34
34
}
35
35
 
36
 
uint16_t uwsgi_rpc(char *name, uint8_t argc, char *argv[], char *output) {
 
36
uint16_t uwsgi_rpc(char *name, uint8_t argc, char *argv[], uint16_t argvs[], char *output) {
37
37
 
38
38
        struct uwsgi_rpc *urpc = NULL;
39
39
        int i;
50
50
 
51
51
        if (urpc) {
52
52
                if (uwsgi.p[urpc->modifier1]->rpc) {
53
 
                        ret = uwsgi.p[urpc->modifier1]->rpc(urpc->func, argc, argv, output);
 
53
                        ret = uwsgi.p[urpc->modifier1]->rpc(urpc->func, argc, argv, argvs, output);
54
54
                }
55
55
        }
56
56
 
57
57
        return ret;
58
58
}
 
59
 
 
60
 
 
61
char *uwsgi_do_rpc(char *node, char *func, uint8_t argc, char *argv[], uint16_t argvs[], uint16_t *len) {
 
62
 
 
63
        uint8_t i;
 
64
        uint16_t ulen;
 
65
        struct uwsgi_header uh;
 
66
        char *buffer = NULL;
 
67
        
 
68
        *len = 0;
 
69
 
 
70
        if (node == NULL || !strcmp(node, "")) {
 
71
                // allocate the whole buffer
 
72
                buffer = uwsgi_malloc(65536);
 
73
                *len = uwsgi_rpc(func, argc, argv, argvs, buffer);
 
74
                return buffer;
 
75
        }
 
76
 
 
77
 
 
78
        // connect to node
 
79
        int fd = uwsgi_connect(node, uwsgi.shared->options[UWSGI_OPTION_SOCKET_TIMEOUT], 0);
 
80
 
 
81
        if (fd < 0) return NULL;
 
82
 
 
83
        // prepare a uwsgi array
 
84
        uint16_t buffer_size = 2 + strlen(func);
 
85
 
 
86
        for (i = 0; i < argc; i++) {
 
87
                buffer_size += 2 + argvs[i];
 
88
        }
 
89
 
 
90
        // allocate the whole buffer
 
91
        buffer = uwsgi_malloc(65536);
 
92
 
 
93
        uh.modifier1 = 173;
 
94
        uh.pktsize = buffer_size;
 
95
        uh.modifier2 = 0;
 
96
 
 
97
        // add func to the array
 
98
        char *bufptr = buffer;
 
99
        ulen = strlen(func);
 
100
        *bufptr++ = (uint8_t) (ulen & 0xff);
 
101
        *bufptr++ = (uint8_t) ((ulen >> 8) & 0xff);
 
102
        memcpy(bufptr, func, ulen);
 
103
        bufptr += ulen;
 
104
 
 
105
        for (i = 0; i < argc; i++) {
 
106
                ulen = argvs[i];
 
107
                *bufptr++ = (uint8_t) (ulen & 0xff);
 
108
                *bufptr++ = (uint8_t) ((ulen >> 8) & 0xff);
 
109
                memcpy(bufptr, argv[i], ulen);
 
110
                bufptr += ulen;
 
111
        }
 
112
 
 
113
        if (write(fd, &uh, 4) != 4) {
 
114
                uwsgi_error("write()");
 
115
                close(fd);
 
116
                free(buffer);
 
117
                return NULL;
 
118
        }
 
119
 
 
120
        if (write(fd, buffer, buffer_size) != buffer_size) {
 
121
                uwsgi_error("write()");
 
122
                close(fd);
 
123
                free(buffer);
 
124
                return NULL;
 
125
        }
 
126
 
 
127
        if (uwsgi_read_response(fd, &uh, uwsgi.shared->options[UWSGI_OPTION_SOCKET_TIMEOUT], &buffer) < 0) {
 
128
                close(fd);
 
129
                free(buffer);
 
130
                return NULL;
 
131
        }
 
132
 
 
133
        close(fd);
 
134
        
 
135
        *len = uh.pktsize;
 
136
        if (*len == 0) {
 
137
                free(buffer);
 
138
                return NULL;
 
139
        }
 
140
        return buffer;
 
141
 
 
142
}