Merge lp:~pedronis/go-dbus/atomic-write-per-conn into lp:go-dbus/v1
Proposed by
Samuele Pedroni
Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | 133 | ||||
Proposed branch: | lp:~pedronis/go-dbus/atomic-write-per-conn | ||||
Merge into: | lp:go-dbus/v1 | ||||
Diff against target: |
98 lines (+13/-15) 3 files modified
auth.go (+2/-2) dbus.go (+10/-5) message.go (+1/-8) |
||||
To merge this branch: | bzr merge lp:~pedronis/go-dbus/atomic-write-per-conn | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
John Lenton | Approve | ||
Review via email: mp+242257@code.launchpad.net |
Commit message
make message writes on a connection atomic (not globally)
Description of the change
make message writes on a connection atomic (not globally)
To post a comment you must log in.
Thank you.
Review: approve
On 19 Nov 2014 19:15, "Samuele Pedroni" <email address hidden>
wrote:
> Samuele Pedroni has proposed merging /code.launchpad .net/~pedronis/ go-dbus/ atomic- write-per- conn/+merge/ 242257 (conn) append( msg, []byte("\r\n")...)) []byte( "BEGIN\ r\n")); err != nil { AddUint32( &p.lastSerial, 1) age(msg *Message) error { Unlock( ) p.nextSerial( )) p.conn) ; err != nil { ssage(msg) lies[serial] = replyChan Unlock( ) p.conn) ; err != nil { ssage(msg) ; err != nil { Lock() p.methodCallRep lies, serial) Unlock( )
> lp:~pedronis/go-dbus/atomic-write-per-conn into lp:go-dbus/v1.
>
> Commit message:
> make message writes on a connection atomic (not globally)
>
> Requested reviews:
> Go D-Bus Hackers (go-dbus)
>
> For more details, see:
>
> https:/
>
> make message writes on a connection atomic (not globally)
> --
> Your team Go D-Bus Hackers is requested to review the proposed merge of
> lp:~pedronis/go-dbus/atomic-write-per-conn into lp:go-dbus/v1.
>
> === modified file 'auth.go'
> --- auth.go 2014-10-22 21:48:27 +0000
> +++ auth.go 2014-11-19 19:15:16 +0000
> @@ -124,7 +124,7 @@
> inStream := bufio.NewReader
> send := func(command ...[]byte) ([][]byte, error) {
> msg := bytes.Join(command, []byte(" "))
> - // writing at this point doesn't not need to be synced as
> the connection
> + // writing at this point does not need to be synced as the
> connection
> // is not shared at this point.
> _, err := conn.Write(
> if err != nil {
> @@ -182,7 +182,7 @@
> return errors.New("Could not authenticate with any
> mechanism")
> }
> // XXX: UNIX FD negotiation would go here.
> - // writing at this point doesn't not need to be synced as the
> connection
> + // writing at this point does not need to be synced as the
> connection
> // is not shared at this point.
> if _, err := conn.Write(
> return err
>
> === modified file 'dbus.go'
> --- dbus.go 2014-11-13 10:14:09 +0000
> +++ dbus.go 2014-11-19 19:15:16 +0000
> @@ -37,6 +37,7 @@
> // The unique name of this connection on the message bus.
> UniqueName string
> conn net.Conn
> + writeLock sync.Mutex
> busProxy BusDaemon
> lastSerial uint32
>
> @@ -251,12 +252,16 @@
> return atomic.
> }
>
> +func (p *Connection) atomicWriteMess
> + p.writeLock.Lock()
> + defer p.writeLock.
> + _, err := msg.WriteTo(p.conn)
> + return err
> +}
> +
> func (p *Connection) Send(msg *Message) error {
> msg.setSerial(
> - if _, err := msg.WriteTo(
> - return err
> - }
> - return nil
> + return p.atomicWriteMe
> }
>
> func (p *Connection) SendWithReply(msg *Message) (*Message, error) {
> @@ -272,7 +277,7 @@
> p.methodCallRep
> p.handlerMutex.
>
> - if _, err := msg.WriteTo(
> + if err := p.atomicWriteMe
> p.handlerMutex.
> delete(
> p.handlerMutex.
>
> === modified file 'message.go'
> --- message.go 2014-10-22 16:08:20 +0000
...