🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #33561

Perl filter article copy (Was: Re: INN and sockets)

#33561
From: Silas Dunsmore
Date: Sat, 05 Dec 1998 00:00
58 lines
2956 bytes
In article <747prt$auu$1@meowhost.meow.invalid>,
Fluffy <gerglery@usa.net> wrote:
>Silas Dunsmore <silasd@user.psyber.com> wrote:
>
>> I must admit that I didn't really like the idea of write-access to the
>> article buffer from the filter.  Let's not make it _easy_ to alter 
>> articles, right?
>
>Had to give it a shot, since there is a huge amount memcpying going on
>in there.  Passing along size hints to avoid the operation in the
>worst cases makes for an okay second-best, I guess, but it just seems,
>I dunno, just ugly.
>
>I wish there was an easy way to work read-only access in there.

Mm-hmm.  I thought I remembered that Perl had some copy-on-write support
for its internals, but when I looked, I didn't find it.  I suspect that I
was thinking of the extra copy made when a (capturing) regexp matches.

I did find a hook that could probably be made to do it, but it looks
like more work than I'd want to do.

[from perlguts.pod]
| 
| Similarly, 'U' magic can be used much like tie() to call a C function
| any time a scalar's value is used or changed.  The C<MAGIC>'s
| C<mg_ptr> field points to a C<ufuncs> structure:
| 
|     struct ufuncs {
|         I32 (*uf_val)(IV, SV*);
|         I32 (*uf_set)(IV, SV*);
|         IV uf_index;
|     };
| 
| When the SV is read from or written to, the C<uf_val> or C<uf_set>
| function will be called with C<uf_index> as the first arg and a
| pointer to the SV as the second.

So it would seem possible to create a copy-on-write of the buffer, and
easier to just discard buffer changes entirely.

But working with "magic" variables is way over my head... I expect it'd
need a Perl-XS guru.  Any takers?

-- 
Later, eh?    Silas

Narrator:      In the 18th Century, he brought the plague to Norway, which has
               gotten blamed for him ever since.  At the Continental Congress
               in 1776, delegates complained about the number of rats in Phila-
               delphia.  By 1859, the Norway rat was known and loathed in San
               Francisco.  By 1872, he had arrived in Honolulu.  This amazing
               little beast had circumnavigated most of the globe in a few
               thousand years.

Dots have followed this migration.

Technical Details
Message-ID: <74bc92$6f4$1@news.psyber.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail
References: <745m4r$7np$1@meowhost.meow.invalid> <746l0n$9bj$1@meowhost.meow.invalid> <747k5t$57m$1@news.psyber.com> <747prt$auu$1@meowhost.meow.invalid>

Show Full Headers
Complete Article Headers
Message-ID: <74bc92$6f4$1@news.psyber.com>
Subject: Perl filter article copy (Was: Re: INN and sockets)
Date: Sat, 05 Dec 1998 00:00:00 +0000
From: silasd@user.psyber.com (Silas Dunsmore)
References: <745m4r$7np$1@meowhost.meow.invalid> <746l0n$9bj$1@meowhost.meow.invalid> <747k5t$57m$1@news.psyber.com> <747prt$auu$1@meowhost.meow.invalid>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail
X-Deja-AN: 418942822
Organization: Psyberware Internet Access
Newsgroups: news.software.nntp