aboutsummaryrefslogtreecommitdiffstats
path: root/rpc
diff options
context:
space:
mode:
authorBas van Kervel <bas@ethdev.com>2015-06-16 17:16:50 +0800
committerBas van Kervel <bas@ethdev.com>2015-06-22 14:54:21 +0800
commit60c2ccd99cd9acdb628a9ba5e16ad0e7e52b7e17 (patch)
tree24ab79f06b1d51b8c0967e6e5f6bedd46ebc710d /rpc
parent9cf7913c61c6f9c1f36a44778a75e6a91a741be4 (diff)
downloaddexon-60c2ccd99cd9acdb628a9ba5e16ad0e7e52b7e17.tar.gz
dexon-60c2ccd99cd9acdb628a9ba5e16ad0e7e52b7e17.tar.zst
dexon-60c2ccd99cd9acdb628a9ba5e16ad0e7e52b7e17.zip
made ipc handler generic and reusable
Diffstat (limited to 'rpc')
-rw-r--r--rpc/comms/comms.go38
-rw-r--r--rpc/comms/ipc_unix.go29
2 files changed, 39 insertions, 28 deletions
diff --git a/rpc/comms/comms.go b/rpc/comms/comms.go
index 244f5a7a6..3f458adfd 100644
--- a/rpc/comms/comms.go
+++ b/rpc/comms/comms.go
@@ -1,7 +1,45 @@
package comms
+import (
+ "io"
+ "net"
+
+ "github.com/ethereum/go-ethereum/logger"
+ "github.com/ethereum/go-ethereum/logger/glog"
+ "github.com/ethereum/go-ethereum/rpc/api"
+ "github.com/ethereum/go-ethereum/rpc/codec"
+ "github.com/ethereum/go-ethereum/rpc/shared"
+)
+
type EthereumClient interface {
Close()
Send(interface{}) error
Recv() (interface{}, error)
}
+
+func handle(conn net.Conn, api api.EthereumApi, c codec.Codec) {
+ codec := c.New(conn)
+
+ for {
+ req, err := codec.ReadRequest()
+ if err == io.EOF {
+ codec.Close()
+ return
+ } else if err != nil {
+ glog.V(logger.Error).Infof("IPC recv err - %v\n", err)
+ codec.Close()
+ return
+ }
+
+ var rpcResponse interface{}
+ res, err := api.Execute(req)
+
+ rpcResponse = shared.NewRpcResponse(req.Id, req.Jsonrpc, res, err)
+ err = codec.WriteResponse(rpcResponse)
+ if err != nil {
+ glog.V(logger.Error).Infof("comms send err - %v\n", err)
+ codec.Close()
+ return
+ }
+ }
+}
diff --git a/rpc/comms/ipc_unix.go b/rpc/comms/ipc_unix.go
index 5a94fd1e0..131fb86f2 100644
--- a/rpc/comms/ipc_unix.go
+++ b/rpc/comms/ipc_unix.go
@@ -3,7 +3,6 @@
package comms
import (
- "io"
"net"
"os"
@@ -11,7 +10,6 @@ import (
"github.com/ethereum/go-ethereum/logger/glog"
"github.com/ethereum/go-ethereum/rpc/api"
"github.com/ethereum/go-ethereum/rpc/codec"
- "github.com/ethereum/go-ethereum/rpc/shared"
)
func newIpcClient(cfg IpcConfig, codec codec.Codec) (*ipcClient, error) {
@@ -40,32 +38,7 @@ func startIpc(cfg IpcConfig, codec codec.Codec, api api.EthereumApi) error {
continue
}
- go func(conn net.Conn) {
- codec := codec.New(conn)
-
- for {
- req, err := codec.ReadRequest()
- if err == io.EOF {
- codec.Close()
- return
- } else if err != nil {
- glog.V(logger.Error).Infof("IPC recv err - %v\n", err)
- codec.Close()
- return
- }
-
- var rpcResponse interface{}
- res, err := api.Execute(req)
-
- rpcResponse = shared.NewRpcResponse(req.Id, req.Jsonrpc, res, err)
- err = codec.WriteResponse(rpcResponse)
- if err != nil {
- glog.V(logger.Error).Infof("IPC send err - %v\n", err)
- codec.Close()
- return
- }
- }
- }(conn)
+ go handle(conn, api, codec)
}
os.Remove(cfg.Endpoint)
olution/commit/widgets?id=26318a84b2c2267613659ba1912d3869a6694fad'>Fixed the border bug. Borders draw properly now.Christopher James Lahey2001-01-051-2/+2 * bump versionJP Rosevear2001-01-051-0/+174 * Added functions for encoding utf8 safely into libxml brokennessLauris Kaplinski2001-01-032-0/+100 * Add support here for "cursor_pos". (et_get_arg): Handle ARG_CURSOR_POS.Miguel de Icaza2000-12-292-5/+35 * Removed a bunch of unused code.Christopher James Lahey2000-12-271-217/+0 * Added a "draw_background" argument. Set the default for theChristopher James Lahey2000-12-272-2/+19 * Connect to the "changed" and "activate" signals on the EText to the proxyMiguel de Icaza2000-12-261-0/+22 * Always have some text. Fixes crash.Miguel de Icaza2000-12-262-1/+1 * Always have some text. Fixes crash.Miguel de Icaza2000-12-262-5/+7 * draw_background=FALSEMiguel de Icaza2000-12-262-0/+3 * Set draw_background to FALSE.Miguel de Icaza2000-12-252-0/+6 * Set draw_background to FALSE.Miguel de Icaza2000-12-251-0/+1 * Made the code CanvasItem correct: the code should not draw at arbitraryMiguel de Icaza2000-12-251-6/+16 * Pass draw_background = FALSEMiguel de Icaza2000-12-252-0/+5 * add api docs.Chris Toshok2000-12-252-0/+57 * Handle draw background. (e_text_draw): Support both border drawing andMiguel de Icaza2000-12-253-50/+106 * Destroy text and pixbuf if they exist whether or not is_pixbuf is set.Christopher James Lahey2000-12-237-27/+51 * translationsJP Rosevear2000-12-233-10/+125 * Set the minimum width of newly created children.Christopher James Lahey2000-12-195-42/+69 * ditto.Miguel de Icaza2000-12-191-2/+2 * Upped the version number to 0.4.1. Bumped the GAL_REVISION to 1.Christopher James Lahey2000-12-161-8/+0 * #include <time.h>Federico Mena Quintero2000-12-153-1/+5 * Removed the set cursor and get cursor methods from ETableGroup.Christopher James Lahey2000-12-155-93/+6 * call set_style and use the appropriate style for the text to determine ifChris Toshok2000-12-151-1/+4 * Commented out an unused variable to fix a warning.Christopher James Lahey2000-12-151-0/+2 * Added eti_visibility_notify. Didn't get it to work properly, so it's #ifChristopher James Lahey2000-12-141-0/+25 * Changed the color from yellow to light gray.Christopher James Lahey2000-12-142-2/+7 * Changed the background color of the tooltips to light gray.Christopher James Lahey2000-12-142-2/+2 * remove the silly logic - we pop up a tooltip regardless of where the mouseChris Toshok2000-12-142-7/+30 * New function to calculate the extra pixels per column header.Christopher James Lahey2000-12-146-27/+82 * only return TRUE in the BUTTON_PRESS case if the node was expandable.Chris Toshok2000-12-141-1/+1 * cut&paste from e-table-sorted-variable.c and massage names a bit to makeChris Toshok2000-12-141-1/+208 * Fixed some warnings.Christopher James Lahey2000-12-121-1/+2 * Made selected rows ignore their color specification.Christopher James Lahey2000-12-121-1/+1 * Emit double_click signal with the model column, not the view column.Dan Winship2000-12-121-1/+1 * Split the lines in this cell before testing whether we're to the right ofChristopher James Lahey2000-12-101-8/+12 * cell should be edit cast to a CurrentCell, not data cast to a CurrentCell.Christopher James Lahey2000-12-101-1/+1 * Added the actions parameter to ect_event. Added an actions field toChristopher James Lahey2000-12-108-62/+112 * Unref the object instead of destroying it.Federico Mena Quintero2000-12-104-4/+4 * If there are columns allocated, free them upon a destroy.JP Rosevear2000-12-092-5/+3 * Work to get a Gtk-Doc infrastructure in place for Gal.Miguel de Icaza2000-12-099-50/+45 * Call the parent class destroyer as wellJP Rosevear2000-12-092-0/+8 * set "sort_info" on our sorter when we get a new sort_info to keep thingsChris Toshok2000-12-082-4/+60 * Add column and GdkEvent * parameters to the double click signal.Christopher James Lahey2000-12-0810-330/+62 * Destroy the gdkIC if we have oneJP Rosevear2000-12-081-0/+5 * Free the xmlDoc when we are done with it. (e_table_state_save_to_file):Federico Mena Quintero2000-12-083-5/+13 * pass along the column's width to e_cell_show_tooltip.Chris Toshok2000-12-075-17/+14 * Adapted these to accept the new flags parameter to e_cell_event.Christopher James Lahey2000-12-076-29/+48 * Removed incorrect e-list.h include.Christopher James Lahey2000-12-071-1/+0 * Missed this file during the last commit.Chris Lahey2000-12-071-2/+4 * Added a GalViewCollection argument to the new function here.Christopher James Lahey2000-12-075-30/+58 * Added gal-view-collection.c, gal-view-etable.c, gal-view-factory-etable.c,Christopher James Lahey2000-12-0717-157/+868 * Fixed warning in compute_elision_length.Christopher James Lahey2000-12-072-18/+0 * disconnect the "group_info_changed" signal on the old sort_info andDan Winship2000-12-071-2/+12 * Move the correct offset when memmoving. Patch provided by Richard HultJP Rosevear2000-12-051-1/+1 * NULL-terminate gal_view_menus_apply's BonoboUIVerb array to prevent aDan Winship2000-12-052-0/+7 * need to zero out the bits corresponding to the rows not selected in theChris Toshok2000-12-041-1/+13 * Federico gets into pixel-perfect neurosis. Xmag is my best friend.Federico Mena Quintero2000-12-036-273/+546 * Move away from unicode_iconv*. We still need libunicode for utf8Dan Winship2000-11-301-25/+9 * ShushJP Rosevear2000-11-291-1/+2 * updated to emit "changed" when appropriate, which turned out to beDamon Chaplin2000-11-275-465/+1185 * Removed e_table_col_get_arrow and e_table_col_set_arrow.Christopher James Lahey2000-11-262-28/+0 * Documented.Miguel de Icaza2000-11-256-29/+212 * inline documentation added.Miguel de Icaza2000-11-253-152/+430 * Save the children - FedericoFederico Mena Quintero2000-11-234-11/+19 * Fixed some typos to get the table to display properly.Christopher James Lahey2000-11-222-3/+3 * AdaptMiguel de Icaza2000-11-181-3/+3 * Add Makefile.am and .cvsignoreMiguel de Icaza2000-11-182-0/+19 * Added widgets/menus that contains the gal-view-menus.c code from Gal thatMiguel de Icaza2000-11-181-1/+2 * Removed test for Bonobo here.Miguel de Icaza2000-11-181-1/+0 * Updated version number.Christopher James Lahey2000-11-143-17/+25 * Added a bunch of .lo s from the menus directory.Christopher James Lahey2000-11-1211-14/+929 * Made the underline show up properly in the main menu bar.Christopher James Lahey2000-11-111-3/+23 * Switched from using gtk_menu_item_new_with_label for the menu header toChristopher James Lahey2000-11-101-1/+1 * Changed the gal version number and the gal so number. Added check forChristopher James Lahey2000-11-103-2/+236 * Fixed two spacing problems: first, changed the spacing around the end ofAnna Marie Dirks2000-11-101-2/+4 * Added decomposing case insensitive utf-8 strstrLauris Kaplinski2000-11-082-4/+1493 * gal/widgets/e-unicode.h: END_GNOME_DECLS, not BEGINJulian Missig2000-11-071-1/+1 * Changed this to match the new EPopupMenu structre.Christopher James Lahey2000-11-071-16/+16 * Add a submenu field to struct EPopupMenu.Jeffrey Stedfast2000-11-072-34/+46 * Fixed the argument comment. Removed an old enum that's not used here.Christopher James Lahey2000-11-071-9/+4 * Added e-search-bar.c and e-search-bar.h.Christopher James Lahey2000-11-072-0/+384 * Removed unnecessary .cvsignore files.Christopher James Lahey2000-11-064-9/+5 * New files for the new define views dialog.Christopher James Lahey2000-11-063-0/+573 * Made it compile again.Chris Lahey2000-11-041-2/+2 * Turned on proper handling of insert and delete.Christopher James Lahey2000-11-041-1/+1 * Removed the "time_changed" signal, since it was never being emitted in theFederico Mena Quintero2000-11-043-59/+81 * Since we insert at the parent->child position, we need to account forNot Zed2000-11-031-39/+117 * Updated these unused glade files to better match the versions in the code.Christopher James Lahey2000-11-035-100/+130 * modified or added a bunch of .cvsignore to ignore generated files, whichGediminas Paulauskas2000-11-013-0/+9 * #include <string.h> to get rid of warning. Same here.Kjartan Maraas2000-10-313-0/+7 * Do not unref the cal_popup since we already destroyed it.Federico Mena Quintero2000-10-282-1/+6 * Added an "allow_newlines" argument.Christopher James Lahey2000-10-276-23/+99 * If we are inserting into the root level, we dont have to search the wholeNot Zed2000-10-271-1/+6 * remove the save_id here, so we don't save state for nodes that no longerChris Toshok2000-10-261-9/+6 * Made the column on the right click and click signals be the model columnChristopher James Lahey2000-10-261-2/+2 * Add "click" to the list of etable signals we proxy.Dan Winship2000-10-262-0/+23 * make ETreeModel opaque, and switch from using g_new0 and g_free forChris Toshok2000-10-252-97/+135 * Destroy the tooltip timeout on object destruction.Christopher James Lahey2000-10-241-1/+8 * Made it so that it doesn't recalculate all the rows if a row is changed,Christopher James Lahey2000-10-222-4/+36 * Made it so that rows inserted with their children nodes already in theChristopher James Lahey2000-10-221-1/+3 * Added e_table_set_state_object which loads the state from the givenChristopher James Lahey2000-10-222-4/+6 * remove timeouts on destroy so they don't try to write to freed dataDan Winship2000-10-202-0/+13 * Made the number keys on the number pad work in ETexts and ECellTexts.Christopher James Lahey2000-10-191-1/+108 * Switched to saving the version as a double instead of a string.Christopher James Lahey2000-10-191-1/+1 * Fixed ETableFieldChooser row heights a bit.Christopher James Lahey2000-10-194-30/+88 * Made EEntry accept focus properly.Christopher James Lahey2000-10-191-0/+11 * Make text a different color if !(flags & E_CELL_FOCUSED).Christopher James Lahey2000-10-194-2/+17 * Sped up signal propogation.Christopher James Lahey2000-10-192-2/+52 * Fixed the color of the background rectangle. Made the rectangle start atChristopher James Lahey2000-10-191-0/+16 * Make background color of ETable match the background color of item rows.Christopher James Lahey2000-10-181-1/+1 * Removed an unnecessary glade include file.Christopher James Lahey2000-10-184-1/+29 * Moved the glade file directories.Christopher James Lahey2000-10-181-1/+2 * Reworked some of the height stuff?Christopher James Lahey2000-10-171-14/+12 * Choose a better size for the e-table-header-itemIain Holmes2000-10-171-17/+53 * get the next child before traversing/calling func.Chris Toshok2000-10-161-2/+5 * get rid of ENode type, as everything in it is now in ETreePath, and addChris Toshok2000-10-162-139/+257 * Made it so that ETable won't use a state with 0 columns.Christopher James Lahey2000-10-161-2/+14 * Fixed these to use the new ascending attribute as a boolean instead of anChristopher James Lahey2000-10-145-11/+11 * Added e-table-config-field.lo.Christopher James Lahey2000-10-1411-228/+704 * NULL is not a valid argument to `xmlNewDoc'. Was this code everEttore Perazzoli2000-10-141-1/+3 * Fixed gdk-font refcountingIain Holmes2000-10-133-34/+51 * Added e_container_focus_nth_entry.Christopher James Lahey2000-10-132-0/+33 * when there are 0 columns, don't assert.Jeffrey Stedfast2000-10-121-1/+1 * Make saving state work properly.Christopher James Lahey2000-10-121-3/+41 * fixed to recalculate min_cell_width/height in case the show_week_numbersDamon Chaplin2000-10-124-45/+211 * Fixed the parity on the cursor-mode check.Christopher James Lahey2000-10-111-1/+1 * Changed these to use the default cells.Christopher James Lahey2000-10-116-50/+13 * Example spec file. Not used. Just an example of what you can do.Christopher James Lahey2000-10-111-0/+21 * Changed these to match the new ETable system.Christopher James Lahey2000-10-1119-308/+1292 * Removed the assertion that there must be at least 1 column. No way toNot Zed2000-10-095-2/+108 * Added missing BEGIN/END_GNOME_DECLSLauris Kaplinski2000-10-091-0/+5 * set cursors to NULL after destroying them, to avoid any possibility ofDamon Chaplin2000-10-081-0/+5 * Emit the selection/cursor "changed" signals.Jeffrey Stedfast2000-10-051-0/+19 * Select all elements of the etable.Jeffrey Stedfast2000-10-054-0/+67 * Changed to take into account the sort group, if the table has one.xNot Zed2000-10-047-18/+428 * Put in 3 more dialog boxes in these files.Christopher James Lahey2000-10-042-75/+1811 * change/add prototypes and a typedef for ETreePathCompareFunc.Chris Toshok2000-10-032-49/+99 * don't screw things up if we sort a collapsed node.Chris Toshok2000-10-031-2/+5 * nukeChris Toshok2000-10-032-1181/+0 * flip black and gray, the way i intended them to be.Chris Toshok2000-10-032-4/+4 * reinstate file.Chris Toshok2000-10-035-24/+103 * better i18n of strftime strings.Damon Chaplin2000-09-303-9/+20 * fixed use of date strings to support i18n better.Damon Chaplin2000-09-303-53/+97 * updated to use new EShortcutBar signals for DnD.Damon Chaplin2000-09-305-14/+98 * Get the title bar for the folder view to use TigerT's pin icon for theEttore Perazzoli2000-09-293-56/+209 * Changed.Christopher James Lahey2000-09-291-0/+0 * New file. Approximate UML description of ETable.Christopher James Lahey2000-09-291-0/+0 * Fix a stupid crash in ::destroy that was my fault.Ettore Perazzoli2000-09-292-2/+7 * Fudge the location of a click in the tooltip, so that it selects theIain Holmes2000-09-273-10/+38 * Fixed emission for "shortcut_dragged".Ettore Perazzoli2000-09-272-1/+7 * drag/drop signals need to be added to the same object that is passed toChris Toshok2000-09-271-9/+9 * Make the shortcut bar not alter the model by itself on a drag and dropEttore Perazzoli2000-09-263-6/+72 * add save_state stuff to ETreeModel, and prototypes for the public methods.Chris Toshok2000-09-262-7/+213 * Fix include typo.Ariel Rios2000-09-251-1/+1 * fix sorting - need to update the row_array as well as the actual structureChris Toshok2000-09-251-4/+20 * use pixmaps instead of GtkArrows to look better. Also set the canvasDamon Chaplin2000-09-258-247/+290 * Fixed operation of the keypad keys in EText and ECellText.Christopher James Lahey2000-09-221-6/+23 * Typo caused readability problems with ETable.Christopher James Lahey2000-09-211-1/+1 * Changed the #ifndef used so that it doesn't collide with one inside ofChristopher James Lahey2000-09-211-3/+3 * Moved files, fixed header files and paths - FedericoFederico Mena Quintero2000-09-2080-172/+176 * set this to 4 to specify how much X/Open we want with that.Dan Winship2000-09-192-1/+6 * Added check for gnome-app-lib. Removed directories that have been moved toChristopher James Lahey2000-09-18155-38212/+120 * Leak prevention.Morten Welinder2000-09-181-2/+8 * Added e-reflow-sorted and e-reflow and fixed the #includes.Christopher James Lahey2000-09-181-4/+4 * doh!Jody Goldberg2000-09-181-6/+6 * Added the src/widgets/pixmaps/ directory.Christopher James Lahey2000-09-181-0/+2 * Removed duplicate $(EXTRA_GNOME_CFLAGS).Christopher James Lahey2000-09-181-1/+1 * Fixed e-table #includes so that it would compile.Chris Lahey2000-09-1833-65/+65 * Changed #include lines to get e-text to compile.Chris Lahey2000-09-184-9/+9 * Move srcs from gnumeric andJody Goldberg2000-09-184-97/+191 * Remove e_create_image_widget functionJP Rosevear2000-09-183-50/+3 * Better calculations for tooltip positionsIain Holmes2000-09-187-20/+41 * Added some missing #includes.Christopher James Lahey2000-09-167-6/+16 * Removed g_printIain Holmes2000-09-163-2/+4 * If the cursor is inside the subcell, call the show_tooltip on it.Iain Holmes2000-09-1618-87/+841 * Fix a crash in draw_button.Iain Holmes2000-09-153-4/+10 * typo/compile fixPeter Williams2000-09-153-4/+4 * Fix some crashes Make double clicking on the header dividers automaticallyIain Holmes2000-09-1525-54/+517 * fix path.Michael Meeks2000-09-142-1/+5 * Added widgets/e-reflow/Makefile. ReplacedChristopher James Lahey2000-09-144-1/+38 * Use underscores for untranslated characters fro Gtk+Lauris Kaplinski2000-09-131-52/+42 * Add a bunch of compile flags to the compilation of `tree-example-2'Ettore Perazzoli2000-09-122-0/+11 * Made bold text calculate widths properly.Christopher James Lahey2000-09-123-34/+88 * Made page up and page down active in the ETable.Christopher James Lahey2000-09-113-6/+92 * Added e_utf8_gtk_editable_get_text and e_utf8_gtk_editable_set_text.Christopher James Lahey2000-09-112-10/+36 * added e-dateedit.[hc] and the test-dateedit app.Damon Chaplin2000-09-11